Quantcast
Channel: Answers by "doomprodigy"
Viewing all articles
Browse latest Browse all 90

Answer by doomprodigy

$
0
0

using UnityEngine;
using System.Collections;
public class Look : MonoBehaviour {
    private Vector3 inputRotation;
    private Vector3 mousePlacement;
    private Vector3 screenCentre;
    void Update () {
    FindCrap();
    transform.rotation = Quaternion.LookRotation(inputRotation);
    }
    void FindCrap () {
    screenCentre = new Vector3(Screen.width * 0.5f,0,Screen.height * 0.5f);
    mousePlacement = Input.mousePosition;
    mousePlacement.z = mousePlacement.y;
    mousePlacement.y = 0;
    inputRotation = mousePlacement - screenCentre;
    }
}

That should give you what you need, incorporate it into your script attached to the to of the tank.


Viewing all articles
Browse latest Browse all 90

Trending Articles



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