Car wont move
So, I'm making my first game in Unity and I wanna make a car to be driveable. I've watched a tutorial and used the code the guy had but. Everything seems ok but the car doesn't move. I've tried useing my arrows keys or WASD keys but still nothing. But the interesting thinks is that when I press A or D key the wheels acually turn, and they even spin when i press W put the car doesn't move at any point. Code below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class car_ctrl : MonoBehaviour {
public void GetInput()
{
m_horizontalIinput = Input.GetAxis("Horizontal");
m_verticalInput = Input.GetAxis("Vertical");
}
private void Steer()
{
m_steeringAngle = maxSteerAngle * m_horizontalIinput;
FLWheel.steerAngle = m_steeringAngle;
FRWheel.steerAngle = m_steeringAngle;
}
private void Accelerate()
{
FLWheel.motorTorque = m_verticalInput * motorforce;
FRWheel.motorTorque = m_verticalInput * motorforce;
}
private void UpdateWheelPoses()
{
UpdateWheelPose(FRWheel, FRWheelT);
UpdateWheelPose(FLWheel, FLWheelT);
UpdateWheelPose(RRWheel, RRWheelT);
UpdateWheelPose(RLWheel, RLWheelT);
}
private void UpdateWheelPose(WheelCollider _collider, Transform _transform)
{
Vector3 _pos = _transform.position;
Quaternion _quat = _transform.rotation;
_collider.GetWorldPose(out _pos, out _quat);
_transform.position = _pos;
_transform.rotation = _quat;
}
private void FixedUpdate()
{
GetInput();
Steer();
Accelerate();
UpdateWheelPoses();
}
private float m_horizontalIinput;
private float m_verticalInput;
private float m_steeringAngle;
public WheelCollider FLWheel, FRWheel;
public WheelCollider RRWheel, RLWheel;
public Transform FLWheelT, FRWheelT;
public Transform RRWheelT, RLWheelT;
public float maxSteerAngle = 30;
public float motorforce = 100;
}
Also I have Rigibody on the model car It's self, screenshot of inspector included. ![alt text][1]
Plus I have box collider on the model. I've scaled the box of the Box Collider to fit the model. ![alt text][2]
I'll provide more screenshot in answer section if you need to help me go through this problem Also here is the tutorial that I watched https://www.youtube.com/watch?v=j6_SMdWeGFI
Your answer
Follow this Question
Related Questions
simple car drift system 0 Answers
Unity3D FollowCam not following player vehicle 0 Answers
Can i Give elivation to car(to fly) using RCC V2 unity 0 Answers
How to set reverse speed limit of car? 0 Answers
How to keep car speed on slants? 0 Answers