P
P
ProgramDevel2020-09-11 09:31:20
Unity
ProgramDevel, 2020-09-11 09:31:20

How to make the camera move behind the object?

There is a ball that spins in all directions and you need to make sure that the camera follows the ball, but does not spin.

Here is the ball code

using UnityEngine;

public class PlayerController : MonoBehaviour
{

    private Rigidbody rigidbody;

    private void Start()
    {    

        Cursor.visible = false;

        rigidbody = gameObject.GetComponent<Rigidbody>();
    }

    private void Update()
    {
    	if (Input.GetKey(KeyCode.W))
    	{
    		rigidbody.AddForce(Vector3.forward * 10f);
    		
    	}
    }

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad, 2020-09-11
@ProgramDevel

Hello, I think this is what you need, just indicate the coordinates of the object and that's it. https://docs.unity3d.com/ScriptReference/Quaternio...

W
WasTabon, 2020-09-11
@WasTabon

You can just throw the camera into an object in the hierarchy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question