playMaker

Author Topic: [SOLVED] Simple question about moving in a direction  (Read 1568 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
[SOLVED] Simple question about moving in a direction
« 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
« Last Edit: December 24, 2018, 02:29:10 PM by Splankton »

Jim132

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Simple question about moving in a direction
« Reply #1 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

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Simple question about moving in a direction
« Reply #2 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

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Simple question about moving in a direction
« Reply #3 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.

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Simple question about moving in a direction
« Reply #4 on: December 24, 2018, 02:28:53 PM »
Works perfect thanks for your help!  :D