playMaker

Author Topic: How do you move toward a vector position using force? [SOLVED]  (Read 1838 times)

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
How do you move toward a vector position using force? [SOLVED]
« on: September 16, 2018, 07:54:56 PM »
If I want to move a physics2d game object to a desired x and y how do I know how much x and y to apply force to move in the direction of the object? Is there an easy way to do this? ??? Similar to Move To action but physics based.
« Last Edit: September 28, 2018, 02:20:28 PM by Gav (HeyBud) »

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: How do you move towards a vector position using force?
« Reply #1 on: September 16, 2018, 08:10:16 PM »
Maybe with iTween Move To with Setting time ?

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: How do you move towards a vector position using force?
« Reply #2 on: September 16, 2018, 08:41:16 PM »
That would be great, but I think I tween move uses translate and not physics force. Am I wrong about that? The problem I'm having is when you translate, collisions are overridden or something. Only using force can you get good physics collisions.
I am beginner to Playmaker.
I don't get what you saying.

I faced a similar issue while started to learn. Found solution here
http://hutonggames.com/playmakerforum/index.php?topic=19365.msg84383#msg84383

:)

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: How do you move toward a vector position using force?
« Reply #3 on: September 17, 2018, 11:11:57 PM »
Yeah, that makes sense. So I guess my question is a math question. how do I calculate the vector i need to plug into 'set velocity' to move in the direction of another position? I want an object to move to another object using physics.  This would be a super useful custom action!



I'm not good at maths.
« Last Edit: September 18, 2018, 12:47:54 AM by Gav (HeyBud) »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you move toward a vector position using force?
« Reply #4 on: September 18, 2018, 02:48:26 AM »
Hi,

 to get a direction, you substract the target position with your current position, that's your direction.

 you then use that as the base vector to apply your force.

 Bye,

 Jean

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: How do you move toward a vector position using force?
« Reply #5 on: September 22, 2018, 08:20:23 PM »
This works thanks. It felt like I was over-complicating the question so i'm glad there's a simple solution.