system
1
Simply, I need to add a constant force to a FPS controller. However, with constant forces, if a camera is attatched to the object, it does not work. So how can I achieve this? I could probably do it without a constant force, but to script something that gives that effect. So is this a better idea?
Well, constant force acts upon a rigidbody. You could add a rigidbody and a collider to your camera.
If you want to move something constantly forward without physics:
ConstantVelocity.js
var velocity : Vector3;
function Update()
{
transform.position += velocity * Time.deltaTime;
}
ConstantAcceleration.js
var acceleration : Vector3;
var velocity : Vector3;
function Update()
{
velocity += acceleration * Time.deltaTime;
transform.position += velocity * Time.deltaTime;
}
If you're using a Character Controller:
ConstantCharacterVelocity.js
var velocity : Vector3;
private var controller : CharacterController;
function Awake()
{
controller = GetComponent(CharacterController);
}
function Update()
{
controller.SimpleMove(velocity);
}