#Car Control with Camera Follow

1 messages · Page 1 of 1 (latest)

knotty phoenix
#

Will start the issues in 8-12 hours. Just to be ready!

knotty phoenix
#

I'm gonna start the process in few minutes, any help is appreciated!

knotty phoenix
#

Alright, let's start over!

#

Now, we're going to start from the Camera issue, which doesn't get into its position when following the car!

#

followCar Script

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class followPlayer : MonoBehaviour
{
public GameObject car;
public Vector3 offset = new Vector3(16, 3, -506);

// Update is called once per frame
void LateUpdate()
{
    transform.position = car.transform.position + offset;
}

}
`

#

The position I want the camera to closely follow!

#

This is when it follows the car!

#

This is how I want it to look like from the angle of the camera.

XYZ = (16, 3, -505)

#

if you want carControll Script then here it is:
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarController : MonoBehaviour
{
public GameObject car;
public GameObject rearRightTyre;
public GameObject rearLeftTyre;
public GameObject frontRightTyre;
public GameObject frontLeftTyre;
public float Speed = 150f;
public float turnSpeed = 10f;

// Update is called once per frame
void Update()
{
 if (Input.GetKey(KeyCode.W))
 {
    //transform.Translate(Vector3.forward * Speed * Time.deltaTime);
    rearRightTyre.transform.Rotate(new Vector3(150f, 0f, 0f) * Speed * Time.deltaTime);
 }
}

}`

#
Unity Learn

Overview: Keep your eyes on the road! In this lesson you will code a new C# script for your camera, which will allow it to follow the vehicle down the road and give the player a proper view of the scene. In order to do this, you’ll have to use a very important concept in programming: variables. Project Outcome: The camera will follow the vehicl...

knotty phoenix
#

The code can't be any easier and don't know what's the problem!

knotty phoenix
#

Here I've been trying to explain!
@hollow totem @nocturne lily

knotty phoenix
#

I've fixed the tyre rotation using the following:
rearRightTyre.transform.Rotate(Speed, 0, 0 * Time.deltaTime);