Hi - I followed the roll - a - ball tutorial, currently WASD controls directional “addforce” movement
How would i script in C# to get my ball to look at my mouse cursor? to give you an idea my ball might have guns on it soon so id like to have an aiming system. so basically i need my ball to look at the position of the mouse and move towards or away from it ( in its direction) when W or S is pressed
here is my current playercontroller code
using UnityEngine;
using System.Collections;
public class playercontroller : MonoBehaviour {
public float speed;
private int count;
public GUIText countText;
// Use this for initialization
void Start () {
count = 0;
setcounttext ();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0, moveVertical);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
Debug.Log("trigger");
if (other.gameObject.tag == "pickup")
{
other.gameObject.SetActive(false);
count = count + 1;
setcounttext();
}
}
void setcounttext()
{
countText.text = "Count : " + count.ToString();
}
}
I have tried a few scripts that i found
online but to no avail - i am beginner/moderate in C# but do not understand enough about transforms to get this without help