View unanswered posts | View active topics It is currently Thu Jan 02, 2025 6:07 pm



Reply to topic  [ 6 posts ] 
 How do I make a bullet go straight? 
Author Message
User avatar

Joined: Mon Oct 19, 2009 9:04 am
Posts: 302
Location: Under Your Bed
Reply with quote
Post 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?


Mon Nov 29, 2010 1:38 pm
Profile YIM
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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)


Mon Nov 29, 2010 2:10 pm
Profile
User avatar

Joined: Sat Oct 17, 2009 2:07 pm
Posts: 127
Reply with quote
Post 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.


Mon Nov 29, 2010 2:28 pm
Profile ICQ
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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.


Mon Nov 29, 2010 2:39 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post 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.


Mon Nov 29, 2010 4:04 pm
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: How do I make a bullet go straight?
Look at akblabla's Whitebot's mod, specifically the handgun.


Mon Nov 29, 2010 5:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.033s | 13 Queries | GZIP : Off ]