Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Ofonna on January 24, 2017, 12:17:25 AM

Title: [solved] restricting max and min position on x axis
Post by: Ofonna on January 24, 2017, 12:17:25 AM
hi guys,

please how do i restrict the max and min position of a 2d object within the view of my orthographic camera, just like math.clamp function works.

i'm trying to set the max and min position of y object on the x axis

thanks!
Title: Re: [help] restricting max and min position on x axis
Post by: jeanfabre on January 24, 2017, 01:37:57 AM
Hi,

 Is your object a Rigidbody?

yes: check out the "Movement Constraint" sample on the Ecosystem. you'll find custom actions on the Ecosystem, like "Rigidbody2dMovePosition" as the movement constraint sample is in 3d, but the concept is the same.

no: check out the game samples on the wiki: https://hutonggames.fogbugz.com/default.asp?W880

and study the egg catcher scene, it features an egg basket that is constraint left and right.

 Let me know if that's still no it :)


 Bye,

 Jean
Title: Re: [help] restricting max and min position on x axis
Post by: Ofonna on January 24, 2017, 03:53:08 AM
Hi Jean,

thanks for the reply, I've looked through the information you sent and i found it pretty helpful however i'm working on a 2D game which will require me shooting contantly and i believe the method used in the tutorial you sent, might cause a break in movement and so i decided to use get vector axis instead of get axis.

then i used clamp float and set position with the variable created in clamp float but it didnt work. i believe there may be something wrong with my logic.
here is a picture.

thanks! 
Title: Re: [help] restricting max and min position on x axis
Post by: Ofonna on January 24, 2017, 03:57:31 AM
I also installed the movement constraint package from the ecosystem but didnt find the rigidbody2dmoveposition.

thanks!
Title: Re: [help] restricting max and min position on x axis
Post by: Ofonna on January 24, 2017, 02:42:48 PM
HI jean,
movement constraint worked, but i'm getting an error in the console saying the component has no rigid body but a script is trying to access it and my object has a jerky movement......i believe its because i'm working with a 2d object
Hi,

 Is your object a Rigidbody?

yes: check out the "Movement Constraint" sample on the Ecosystem. you'll find custom actions on the Ecosystem, like "Rigidbody2dMovePosition" as the movement constraint sample is in 3d, but the concept is the same.

no: check out the game samples on the wiki: https://hutonggames.fogbugz.com/default.asp?W880

and study the egg catcher scene, it features an egg basket that is constraint left and right.

 Let me know if that's still no it :)


 Bye,

 Jean
Title: Re: [help] restricting max and min position on x axis
Post by: Ofonna on January 24, 2017, 06:23:45 PM
i was able to figure it out thanks!

get position

clamp float

set position