- Home /
Look in movement direction
So I'm making this motorcycle game where I want it to be possible to drift the bike. And to make the vehicle handling feel more dynamic and fun, I want the camera to look in the direction that the vehicle's moving.`using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraScript : MonoBehaviour { Vector3 OldPosition; Vector3 Direction; public Transform Bike; // Use this for initialization void Start () {
}
// Update is called once per frame
void FixedUpdate () {
transform.position = Bike.transform.position;
Direction = Bike.transform.position - OldPosition;
transform.InverseTransformDirection(Direction);
OldPosition = Bike.transform.position;
}
} ` I've written the above code, but it seems to do... absolutely nothing. The camera continues to look straight ahead, even with a fairly high sideways speed. What the heck do I do to make it work?
Your answer
![](https://koobas.hobune.stream/wayback/20220612141921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera rotating with physics based movement. 0 Answers
Orbit cam and Rigidbodies aiming 0 Answers
Camera/Direction Rotation 2 Answers
rotate around with physics 1 Answer