Data Realms Fan Forums
http://forums.datarealms.com/

A sine projectile?
http://forums.datarealms.com/viewtopic.php?f=73&t=45520
Page 1 of 1

Author:  war_man333 [ Wed Dec 18, 2013 10:20 am ]
Post subject:  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.

Author:  Arcalane [ Wed Dec 18, 2013 10:31 am ]
Post subject:  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.

Author:  war_man333 [ Wed Dec 18, 2013 10:35 am ]
Post subject:  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.

Author:  Abdul Alhazred [ Wed Dec 18, 2013 12:14 pm ]
Post subject:  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.

Author:  war_man333 [ Wed Dec 18, 2013 12:24 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/