playMaker

Author Topic: AddForce relative to direction. [SOLVED]  (Read 5053 times)

MajorIdea

  • Full Member
  • ***
  • Posts: 131
AddForce relative to direction. [SOLVED]
« on: December 31, 2012, 10:52:35 AM »
Hi, is there a way of using playmaker to make a propeller that pushes the player in the direction the propeller is facing?

The way I have it now I'm using an addforce to the player in world space. I have to tweak the values for each one to make it go in the direction it should. But thats a terrible system and it doesn't work if the propeller is on something that rotates and changes direction.

I've looked into the AddForce expample in the testlabs but that seems to be specific to mouse picking and cant figure out how to adapt it http://www.hutonggames.com/sampleScenes/AddForce/AddForce.html

Any help would be greatly appreciated.
Happy 2013!
« Last Edit: January 02, 2013, 01:11:12 PM by MajorIdea »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: AddForce relative to direction.
« Reply #1 on: December 31, 2012, 11:43:22 AM »
"transform Direction" is likely what you're looking for. transform a local force direction from the propellor to a global one which you can then apply on your player as force.
Best,
Sven

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: AddForce relative to direction.
« Reply #2 on: January 02, 2013, 12:20:32 PM »
Err, so I've been trying to figure out how to do that (or even what that meant) with no luck. Any additional pointers? How do I transform a local force direction using that?

Thank you for the support  :)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: AddForce relative to direction.
« Reply #3 on: January 02, 2013, 12:36:07 PM »
create a vector3 variable called DirectionOrig and then one called DirectionCur.
then use the transformDirection action in your FSM. Set the gameObject to your propellor gameObject. Set the direction value to your DirectionOrig and set the output vector3 to your DirectionCur. Check Every frame. Now use your Direction Cur in an addForce action with the target being your character and the space being world.

Now all you need to do is to set the Direction Orig to something that makes it point towards the axis the propellor should fly. Like, if it points up the vector3 would be 0,1,0.  Make sure you check it in local/self space.

This makes it recalculate the direction from local space of the propellor into global space, which you can then globally(world) apply on any other gameObject. If the propellor rotates, the directionOrig will put out a different direction.

Do you want pics? It's actually quite simple once you've understood the principle of those transform actions. They can be a real pain in complex situations :D
« Last Edit: January 02, 2013, 12:38:09 PM by kiriri »
Best,
Sven

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: AddForce relative to direction.
« Reply #4 on: January 02, 2013, 12:42:57 PM »
That does sound pretty complicated, but I shall do my best! You've described it spectacularly so no pics are needed xD

I'll let you know how it goes. Thanks a bunch!

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: AddForce relative to direction.
« Reply #5 on: January 02, 2013, 01:10:40 PM »
IT LIVES!

I had to uncheck the Every Frame on the Transform Direction because the force is applied when the player is On Trigger Stay, so it wouldn't go back to check if it was still on the triggers and the force would only be applied in one frame (cant have the Every Frame checked on the add force because that makes it go forever).

I don't think I need it since It will reload the action every time the player enters the propeller trigger and the propelled itself rotates rather slowly.

So yea. Thanks kiriri! You the man.  :D