# playMaker

### Author Topic: circular constraint  (Read 1920 times)

#### mallenroh

• Playmaker Newbie
• Posts: 31
##### circular constraint
« on: January 23, 2014, 10:20:02 AM »
what would be the best way to limit the motion of an object within a circular radius?

• Full Member
• Posts: 185
• Derp
##### Re: circular constraint
« Reply #1 on: January 23, 2014, 01:05:08 PM »
If you want the object to move along a circular path (like a planet orbiting the sun), parent the moving object to an empty game object. The empty game object should be placed at the center of the desired circular path. When you rotate the empty object, the parented object will move along a circular path around the empty object.

If you just want to constrain a free-moving object within a circular field, use a sphere or a cylinder as a collider!

#### mallenroh

• Playmaker Newbie
• Posts: 31
##### Re: circular constraint (radial constraint)
« Reply #2 on: January 24, 2014, 01:27:31 AM »
I guess I really meant a radial constraint, ideally mathmatically defined, instead of with physics. I want to be able to limit a joysticks movement to be of a defined radius, so it is free to move witthin the given radius, but will clamp out and not go past this limit.

#### escpodgames

• Hero Member
• Posts: 687
##### Re: circular constraint
« Reply #3 on: January 24, 2014, 05:43:45 AM »
I guess you want to use a clamp magnitude of the position, check out the action for this.

#### jeanfabre

• Hero Member
• Posts: 15453
• Official Playmaker Support
##### Re: circular constraint
« Reply #4 on: January 24, 2014, 06:42:59 AM »
Hi,

That will be a little more involving actually.

Basically you need the following:

-- a center position acting as the reference of your constraint

with this, everyframe you check of the position of your gameobject, and create a vector 3 of the position minus the center position, this will give you two indications,

-- the magnitude and the direction.

if the magnitude of greated than the radius, normalize this vector, and multiply it by the radius, that will be the delta position from the center position of your gameobject.

If you do this sequence, then you can still control the gameobject around, it will move within this constraint.

bye,

Jean