I’m having a very frustrating problem with the LookAt() function.
My object (a triangle with a box collider) completely disappeared when I introduced the function in the control script.
Can anyone help me? Here’s the code:
public string PlayerName;
public float Speed;
private Rigidbody2D thisBody;
// Use this for initialization
void Start () {
Debug.Log("Player control online");
thisBody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector2 movement = new Vector2(moveHorizontal, moveVertical);
thisBody.velocity = movement * Speed;
Vector2 LookPos = new Vector2(Input.mousePosition.y, Input.mousePosition.x);
thisBody.transform.LookAt(LookPos);
Thank you for the attention!