- Home /
A form of SimpleMove, without the CharactherController
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).
Answer by gannaz · May 20, 2014 at 08:28 AM
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);
}
}
Your answer
Follow this Question
Related Questions
Android Joystick Control without CharacterController 0 Answers
Rigidbody causes ragdoll character to fly 4 Answers
Rigidbody physics behaving differently from editor to build 0 Answers
Problems with custom controller 1 Answer
Making a haybale forkable 0 Answers