Hey! My suggestion is to allow raycasting in Lua. To implement , for example, self-driving vehicles . I think a good usage would be: Code: physics.raycast(float3 origin,float3 direction,long layermask = 0xFFFFFFFF, float distance = 1) returns a reference to the object in T3D or if it didn't hit, returns nil. --and physics.linecast(float3 origin,float3 end,long layermask = 0xFFFFFFFF) returns a table with hit info or nil
Could you explain in a noob understandable way what raycast is, and what does it provide? Like, I don't have the slightest idea of what you are talking about. Looks interesting, thanks.
Raycast casts a ray in the specified direction at a certain length. If it hits an object it would return the info of the object, and if it never hits anything it would return nil. Linecast is a version of raycast where instead of a direction and length , you only pass in 2 point parameters and it raycasts between the 2.
Vehicle AI. if(physics.raycast(obj:getPosition(),{0,1,0},1) then --Vehicle collision imminent. Stop! end
Dynamic altimeter perhaps, for aircraft? Radar guns? night vision? Sounds like a software "radar" to me.
I wouldnt say most (im assuming youre talking about hitscan) Maybe games like CoD and TF2 use it, but more "realistic" games like battlefield (the more recent ones), Arma etc use much more complicated ways of detecting a hit.
Hitscan is simply a raycast. Generally you find few shooters bother with true projectile simulation, its more CPU demanding for what is usually little gain. Bullet penetration through a surface and bouncing don't require projectile simulation, that can actually be done by creating a new raycast from the landing point of the first ray. ARMA does use full projectile even going as far as considering the recoil of the firearm against the soldier and how that would alter the bullet leaving the barrel. Battlefield and halo are both notable for being a hybrid. The source engine supports both but for most weapons uses hitscans (half life 2 crossbow is an example of being a genuine projectile). The weirdest one is fallout, hitscans all round *unless* the game decides its going to be a critical hit in which case its projectile, there are mods to switch it to full projectile.
There are several ways shooters look for projectile hits, here are 3 examples. 1) Actually physically simulating the projectile, weight, etc affects it. Ideal for tank projectiles, mortar projectiles, etc that would need a visual as well. Requires the most CPU use, and faster physics timesteps. Inefficient for small projectiles that would come out of an SMG or similar. 2) Faking physics. Shooters with only light weaponry such as pistols and light machine guns will use a method like this. It will, upon firing, check if it is going to hit anything. If it hits anything then it will send a "message" to that object saying it has been hit 3) A light simulation of the projectile. Only distance and direction are simulated. This way allows for sound and visual simulation, and is much lighter on the CPU as well.
I believe the vehicle would be able to "analyze" the surroundings. Ex. AI controlled car would be able to avoid obstacles (I believe) (or even follow and enclosed track, i believe still).
I know what it could be used for! Look at my Suggestion post ;D http://www.beamng.com/threads/12092-Crash-Prevention-System?p=188624#post188624