Hello~!
I’m a beginner-level game developer, and I’m trying to create custom driving physics for my racing game.
I’d like to know how I could utilize the primary Script of my car - known as “Car_Move.cs” - to directly access and control two other scripts attached to my car (known as “Simple_Car_Rotation.cs” and “Simple_Car_Steering.cs”) using the Arrow Keys. I’m trying to use Car_Move to do two things:
-
Synchronize the movement of the car’s rear wheels (attached to Simple_Car_Rotation) with the movement of the car body so that both the car body and the all of the wheels move forward.
-
Synchronize the rotation of the car’s front wheels (attached to Simple_Car_Steering) so that the car turns in the same direction the front wheels are facing.
My current setup for the Car_Move Script is this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Car_Move : MonoBehaviour
{
public GameObject Car_Root;
private Simple_Steering_Script SimpleSteering;
private Simple_Rotation_Script SimpleRotation;
private void Awake()
{
SimpleSteering = GetComponent<Simple_Steering_Script>();
SimpleRotation = GetComponent<Simple_Rotation_Script>();
}
void Start()
{
}
void Update()
{
if (Input.GetKey(KeyCode.UpArrow))
transform.Translate(new Vector3(0f, 0f, 35f));
if (Input.GetKey(KeyCode.DownArrow))
transform.Translate(new Vector3(0f, 0f, -15f));
}
}
If anybody could help me figure this out, I’d be immensely grateful. Thank you in advance to anyone and everyone who helps out, and I look forward to hearing from you~!
Sincerely,
- Samuel Pierce