- Home /
Question by
Chris12345 · Mar 13, 2013 at 09:09 PM ·
Simple script problem?
he can i get this to screen wrap long the x to, not only the y?
#pragma strict
var wrap:Vector2;
var wrapMax:Vector2;
function Awake(){
var wrapmin:Vector3=Camera.main.ScreenToWorldPoint(Vector3(0,0,Camera.main.transform.position.y));
wrap=Vector3(wrapmin.x-1,wrapmin.x-0.4);
var wrapmax:Vector3=Camera.main.ScreenToWorldPoint(Vector3(Screen.width,Screen.height,Camera.main.transform.position.y));
wrapMax=Vector3(wrapmax.x+1,wrapmax.x+0.4);
}
function Update () {
if(transform.position.y>wrapMax.y){
transform.position.y=wrap.y;
}
if(transform.position.y<wrap.y){
transform.position.y=wrapMax.y;
}
}
Comment
Answer by GuyTidhar · Mar 13, 2013 at 11:13 PM
Why don't you just add this in the update function, right before the 'y' wrapping?
if(transform.position.x>wrapMax.x){
transform.position.x=wrap.x;
}
if(transform.position.x<wrap.x){
transform.position.x=wrapMax.x;
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Adding a player to a list 0 Answers
GameObject' does not contain a definition for `Find' 1 Answer
Networking woes - Client causing Server to "Reset" upon Loading a Level 1 Answer
accessing a variable from one script in another with Unity 1 Answer