Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mallenroh on January 23, 2014, 10:20:02 AM

Title: circular constraint
Post by: mallenroh 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?
Title: Re: circular constraint
Post by: Breadman 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!  ;D
Title: Re: circular constraint (radial constraint)
Post by: mallenroh 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.
Title: Re: circular constraint
Post by: escpodgames 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.
Title: Re: circular constraint
Post by: jeanfabre on January 24, 2014, 06:42:59 AM

  That will be a little more involving actually.

 Basically you need the following:

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

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.