system
1
i am new to Unity3d and Java Script - but have some experience with flash AS3
I wish to moving an object slow to x position - but if the X i >1000 then move to x800
in AS3:
myObject.x += 10;
if (myObject.x > 1000){
myObject.x = 800}
How i javascript??
3dDude
2
function Update () {
myObject.transform.position.x += 10;
if (myObject.transform.position.x > 1000){
myObject.transform.position.x = 800;
}
}
system
3
You should use Mathf.Clamp(); to control object position.
ex : transform.position.x = Mathf.Clamp(transform.position.x,0,800);