Re: How do I make a bullet go straight?
Here's one way to do it:
1. Set GlobalAccScalar to 0.
2. Set AirResistance to a desired value, preferrably something pretty small.
3. Attach following Lua script to the bullet:
Code:
function Update(self)
-- Do this every frame update
if self.Vel.Magnitude < *velocity goes here* then
-- Is the velocity lower than the given value?
self.Vel = self.Vel + (SceneMan.GlobalAcc * TimerMan.DeltaTimeSecs);
-- If so, add velocity corresponding to the gravity of the scene
end
end
And that's about it. In case you're wondering about the TimerMan part, it's because scenes have their gravity listed as acceleration per second, not per frame. DeltaTimeSecs is how many seconds pass during one frame, which is 60 by default. Writing it as the variable makes it more flexible though, in that people sometimes screw around with DeltaTime, which can make constants act weird.