- Home /
touch moving object
Hello everyone... do you know how to touch the screen anywhere and can move object...left right? here is my code but it doesn't work well
function Update(){
var movement : Vector3;
for(var touch :Touch in Input.touches){
var ray=Camera.main.ScreenPointToRay(touch.position);
var hit : RaycastHit;
if(touch.phase==TouchPhase.Began && Physics.Raycast(ray,hit)){
print(touch.position.x);
}
if(touch.phase==TouchPhase.Moved && Physics.Raycast(ray,hit) || Input.GetKey("a")){
if(touch.position.x>0){
print("is Moving");
}
}
}
}
Comment
can you put spaces where the line of code has finshed like
hi make it look like
this
The spaces were there, you just need to put spaces in front of them (four of them).
Your answer
Follow this Question
Related Questions
make background run loop 1 Answer
swing to hit a target 1 Answer
Working FPS Control on iPad? 1 Answer
Need help combining code 1 Answer
How to export .ipa from Unity? 2 Answers