Blockland Forums > Modification Help
What would be the function that sets a delay of a raycast judging by distance?
<< < (3/7) > >>
Port:
Shouldn't it simply be distance / muzzle velocity * 1000 milliseconds?
Nexus:

--- Quote from: Port on January 16, 2012, 11:53:40 AM ---Shouldn't it simply be distance / muzzle velocity * 1000 milliseconds?

--- End quote ---

d = v*t

t = d/v

yerp
Ipquarx:
You have to split up the raycast into sections each a set length (possibly with a remainder at the end), and delay each raycast by a certain ammount. This makes it work just like a real bullet would.

brians would not work properly because things can move in and out of the way while the bullet is still in the air, which means someone could get blown up even when their not in the path of the bullet.

If you know the basics of math you should be able to figure out the first part easily, but the second part requires some thinking.
Port:

--- Quote from: Nexus on January 16, 2012, 11:59:50 AM ---d = v*t

t = d/v

yerp

--- End quote ---

vectorDist( %start, posFromRaycast( %ray ) ) / %speed * 1000


--- Quote from: Ipquarx on January 16, 2012, 12:12:01 PM ---You have to split up the raycast into sections each a set length (possibly with a remainder at the end), and delay each raycast by a certain ammount. This makes it work just like a real bullet would.

brians would not work properly because things can move in and out of the way while the bullet is still in the air, which means someone could get blown up even when their not in the path of the bullet.

If you know the basics of math you should be able to figure out the first part easily, but the second part requires some thinking.

--- End quote ---

This would decrease the framerate slightly every time a raycast projectile is fired, also decreasing it considerably in an active battlefield with many players doing this. Raycasts are expensive in computing power.
Ipquarx:

--- Quote from: Port on January 16, 2012, 02:24:06 PM ---vectorDist
--- End quote ---
Or if you're a math guy like me:




--- Quote from: Port on January 16, 2012, 02:24:06 PM ---This would decrease the framerate slightly every time a raycast projectile is fired, also decreasing it considerably in an active battlefield with many players doing this. Raycasts are expensive in computing power.
--- End quote ---
Raycasts are not "expensive" in computing power. I've set a raycasting guns fire rate to 50 a second and had 25 people firing it all at once with a latency increase of only 100ms.

EDIT: whats with the ~reserved~. It's Fing pointless in a coding help topic.
Navigation
Message Index
Next page
Previous page

Go to full version