Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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!
-
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
-
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!
-
I also installed the movement constraint package from the ecosystem but didnt find the rigidbody2dmoveposition.
thanks!
-
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 objectHi,
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
-
i was able to figure it out thanks!
get position
clamp float
set position