I'm trying to create an area which has a wind which pushes my character backwards, without using a rigidbody (as I've heard this can cause issues). I've been using the answer from a basically identical question found on this site here:
However, the answer was written with C#, and I'm trying to keep all of my code in javascript. I tried converting it, but I've obviously made an error somewhere due my very limited understanding of C#. Heres the script as it stands in my project.
var direction : Vector3;
var speed = 2.0;
var ctrl : CharacterController;
direction = Vector3(0,1,0);
function OnTriggerStay (other : Collider) {
ctrl = other.gameObject.GetComponent(CharacterController);
if (ctrl) {
ctrl.SimpleMove(direction * speed);
}
}
I may have oversimplified somewhere. As is, my code doesn't work at all. Where am I going wrong?
P.S, sorry for butchering someones much more elegant code XD
My problem has turned out to be that my character is restricted from moving in the Z axis. I can't seem to find a way to allow this movement (i'm not even sure where it's restricted). Anyone have any ideas?
– anon38117566