Now I’m pretty new to custom made character controls. But I’m trying to make a car game, where the cars can be affected by rigid-body mechanics. So that if a car is hit by a cannonball. The car will get affected, in the form of maybe getting thrown across the map. I’m not sure, but my experience says the the Character-controller does get affected by rigid-bodies affecting on it.
So how could I make the car move (with collision detection).
Here I will give you a simple player movement script enabling you to move left right up and down and you can edit it if you want to change rotation and stuff
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float moveSpeed;
private float maxSpeed = 5f;
private Vector3 input;
private Vector3 spawn;
// Use this for initialization
void Start () {
}
void FixedUpdate () {
input = new Vector3(Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));
if(rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce(input * moveSpeed);
}
}