# playMaker

### Author Topic: Adding force in local space direction  (Read 1001 times)

#### 3D Lunatic

• Playmaker Newbie
• Posts: 17
##### Adding force in local space direction
« on: October 24, 2019, 10:07:50 PM »
To summarize, I have a 2D game with physics. I want to add force to a ball object when it goes over a triggered area. I want to add the force in the local Y direction of the trigger zone, so that I can simply rotate the trigger zone if I want to push the ball in a different direction.

Add Force 2D doesn't have a selection for world/local space. It gives the option of using a vector as well as a vector3 (not sure why, it's a 2D physics action). How do I set the vector in such a way that it will apply the force in the local Y direction of my trigger zone?

For reference, my ball object is called Ball, and the trigger zone is called Speed_Booster. I just want to give the ball a push. Thank you for your help.

#### djaydino

• Hero Member
• Posts: 5383
##### Re: Adding force in local space direction
« Reply #1 on: October 25, 2019, 06:22:49 AM »
Hi.
Have you tried 'Add Relative Force 2d' ?

#### 3D Lunatic

• Playmaker Newbie
• Posts: 17
##### Re: Adding force in local space direction
« Reply #2 on: October 25, 2019, 08:45:21 AM »
Add Relative Force 2D is a step in the right direction.

The problem is the direction of the force is based on the orientation of the ball. I want it to be based on the orientation of the Speed Booster. What I need to do (I think) is to capture the rotation of the Speed Booster zone in some Vector2 or Vector3 variable, and then use that vector to apply the force to the ball.

Do you know how to set that up? I just need the actions that should be used, I can create the FSM logic. The Speed Booster is just a rectangle trigger zone with a sprite, like a chevron that points in the direction of the boost.

In summary: How to capture rotation of the Speed Booster chevron, and where to apply it in Add Relative Force 2D. Thank you for your patience, I'm a newbie.

#### jeanfabre

• Hero Member
• Posts: 15396
• Official Playmaker Support
##### Re: Adding force in local space direction
« Reply #3 on: November 12, 2019, 11:34:43 PM »
Hi,

you need to use TransformDirection which will give you a world direction based on a local vector ( vector(0,0,1) would be local forward), then use a regular add force since you have now the direction of the force in world space.

Bye,

Jean