- Home /
transform.position.x ?
Hi,
Im working on a 2D vertical platformer. ive locked the x axis of my camera and it will only follow the player when it moves up. This works.
Now when my player exits the screen on the left side i want him to enter the screen on the right side and vice versa.
This is what i got so far.
var target:Transform;
function start()
{
if(target.transform.position.x > 60)
{
target.transform.position.x = (-40);
}
}
Comment
Best Answer
Answer by Piflik · Jan 05, 2013 at 03:48 PM
Your code will only be run on Start(). You need to put the code into Update()
function Update() {
if(target.position.x > 60) target.transform.x = -40;
if(target.position.x < -40) target.transform.x = 60;
}
Your answer
Follow this Question
Related Questions
Prevent changing position 1 Answer
Inverting Position on One Axis 0 Answers
How to Properly Translate Across Single Axis? 0 Answers
Lock main camera on x-axis 2 Answers