View unanswered posts | View active topics It is currently Thu Dec 26, 2024 3:51 am



Reply to topic  [ 5 posts ] 
 A sine projectile? 
Author Message
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post A sine projectile?
Code:
function Create(self)

   self.lifeTimer = Timer();
   self.Vel = self.Vel*0.50;

end

function Update(self)
   self.AngularVel = 10;
   if self.lifeTimer:IsPastSimMS(5000) then
      local explosion = CreateMOSRotating("Ronin RPC Explosion");
      explosion.Pos = self.Pos;
      explosion:GibThis();
      MovableMan:AddParticle(explosion);
      self.ToDelete = true;
   else
      self.ToDelete = false;
      self.Vel = self.Vel*1.03;
   end

end


You're looking at a projectile which is coming out of a gun.
I want the projectile to travel along the curve of a sine function, because it would be badass.
The thing is, the only way to set motion is through a property called Velocity(?), which is given through a vector.

I can change the projectile's velocity every time Update() runs (every tick I think)

http://wiki.datarealms.com/LuaDocs/MovableObject


What it does:
Image

What I want:
Image

Any good ideas?
Right now it just flies faster and faster.


Wed Dec 18, 2013 10:20 am
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: A sine projectile?
Right, because you're just multiplying the Velocity by its previous value*. All that'll do is net you a slow and steady speed increase, because you're not telling it to alter its facing or angle or anything.

You'll need to modify the AngularVel or RotAngle instead and/or as well. This will probably involve timers and/or fancy math to make sure it curves back and forth properly.

Unfortunately I'm not very good with Lua, but there are a few others around who should be by to help soon enough.

*e.g.;
Tick 1; Vel 10 * 1.5 = 15
Tick 2; Vel 15 * 1.5 = 22.5
Tick 3; Vel 22.5 * 1.5 = 33.75
...and so on.


Wed Dec 18, 2013 10:31 am
Profile YIM
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: A sine projectile?
Yup I'm aware of this. I'm good with math but I don't understand the lua syntax too well.

I tried doing something like self.Vel = Vector(math.sin(somethingHere),math.cos(somethingElseHere))

but it wouldn't accept that line.


Wed Dec 18, 2013 10:35 am
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: A sine projectile?
I posted something similar in this thread: viewtopic.php?p=313515#p313515
I'm not sure if it is what you are looking for, or if it works with this version of CC but it might be a starting point.


Wed Dec 18, 2013 12:14 pm
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: A sine projectile?
This is almost exactly what I'm looking for.
This is for personal use (just making some weapons and stuff for the heck of it) so I'll borrow some of your code.
I won't release it, so you won't notice. :grin:
Thanks for the help.


Wed Dec 18, 2013 12:24 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.032s | 15 Queries | GZIP : Off ]