Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Splankton on December 19, 2018, 05:17:38 PM

Title: [SOLVED] Simple question about moving in a direction
Post by: Splankton on December 19, 2018, 05:17:38 PM
Hi,
I have a 2d object moving from position A, to position B.

How do I get the object to move from position A, in the direction of position B?  So the object doesn't stop when it reaches B, it just keeps moving in the same direction.
Thanks
Title: Re: Simple question about moving in a direction
Post by: Jim132 on December 19, 2018, 07:37:26 PM
Maybe you can store the gameObject of the player B into a variable, get that object's position every frame, make Player A move towards it. Maybe you can add a trigger collider to Player B. After Player A enters the trigger of Player B, it will not follow the Player B's position, but will continue to translate in the current direction.

I'm not sure if this is the right way, but I hope it can help you! ;D
Title: Re: Simple question about moving in a direction
Post by: Splankton on December 23, 2018, 03:47:02 PM
hi, thanks for your help but its not quite what I want.  I just need a gameobject (say a weapon) that gets a target position in 2d, then moves towards it.  Then if the target position moves, I need the weapon not to change its direction, just to continue on its original projection.   Sorry, I should've explained it better before.   I can get it working, but the weapon stops at its target (using MoveTowards action) and I just want it to keep moving in the same direction.
Thanks for any help
Title: Re: Simple question about moving in a direction
Post by: Athin on December 23, 2018, 09:32:54 PM
What you can do is spawn an object at the target location and use the move towards action to that target.  Then you can simply add that target as a child to the projectile.  Doing that will continually move that target away as the projectile gets closer (Think carrot on a stick).

Depending on your set up, you may have to do some tweaking but I think that's an easy way to solve your problem.
Title: Re: Simple question about moving in a direction
Post by: Splankton on December 24, 2018, 02:28:53 PM
Works perfect thanks for your help!  :D