Data Realms Fan Forums http://45.55.195.193/ |
|
How do I make a bullet go straight? http://45.55.195.193/viewtopic.php?f=1&t=20371 |
Page 1 of 1 |
Author: | Joesycop [ Mon Nov 29, 2010 1:38 pm ] |
Post subject: | How do I make a bullet go straight? |
How do I make it go straight until it starts to curve from loss/gain of speed? |
Author: | Azukki [ Mon Nov 29, 2010 2:10 pm ] |
Post subject: | Re: How do I make a bullet go straight? |
Sooo you want the bullet to go perfectly straight until it slows to a particular speed due to air resistance, and then gravity kicks in and it starts to fall? That could easily be done with a simple Lua script. Or it could be done slightly better with a more complicated script. If you just want a flatter trajectory in general, that's easy, just decrease GlobalAccScalar, or increase FireVelocity. (although the latter would effect the damage, and the prior would look crummy once it slows down due to ricochets/air resistance) |
Author: | Mad Alex [ Mon Nov 29, 2010 2:28 pm ] |
Post subject: | Re: How do I make a bullet go straight? |
Let me give you shorter answer: Code: GlobalAccScalar = 0 It's all you need. Gravity won't affect your bullet. |
Author: | Azukki [ Mon Nov 29, 2010 2:39 pm ] |
Post subject: | Re: How do I make a bullet go straight? |
But he seemed to want it to 'curve from loss/gain of speed', which didn't really make sense, so I assumed he wanted gravity to kick in eventually, after maximum effective range, or something like that. So I gave the full set of answers, including yours, to be sure to be helpful in any case, and if that's too much for someone to care to read, maybe they should be more clear with their question. |
Author: | Shook [ Mon Nov 29, 2010 4:04 pm ] |
Post subject: | 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. |
Author: | Roast Veg [ Mon Nov 29, 2010 5:37 pm ] |
Post subject: | Re: How do I make a bullet go straight? |
Look at akblabla's Whitebot's mod, specifically the handgun. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |