Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

How to make an object move relative to the finger

$
0
0
I have a IOS game kinda like asteroids and I want the object to move up and down when the finger moves up and down Can someone make it this line make the object move up and down then the finger is moved up and down? transform.Translate(Input.GetAxisRaw("Vertical")Time.deltaTimebananaSpeed); Full Code: #pragma strict var bananaSpeed:float = 0; var laser : GameObject; var lastShot: float; var FireRate: float; function Start () { } function Update () { for (var touch : Touch in Input.touches) { if(touch.phase == TouchPhase.Began) { Fire(); } } transform.Translate(Input.GetAxisRaw("Vertical")*Time.deltaTime*bananaSpeed); transform.position.x=Mathf.Clamp(transform.position.x,-1,1); transform.position.z=Mathf.Clamp(transform.position.z,-1.89,1.94); } function Fire() { lastShot = Time.time; Instantiate(laser, transform.position, Quaternion.Euler(0,0,-90)); }

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>