- Home /
Adding Constant Force to a CharacterController using the ThirdPersonController script WITHOUT using a RigidBody
I have asked a question similar to this, but didn't get a clear answer. Basically, I want to have these trigger based areas where the player is being pushed in a constant direction even with the players movement acting as resistance.
I don't want to use RigidBodys, because they don't seem to work well when the CharacterController is attached (and I will be using it) as well as the ThirdPersonCOntroller script being in charge of the player's motion and Gravity.
Examples I what I want to use it for:
Conveyor Belts
Wind
Possibly ice
Slippery Slopes (if anyone could help me here, I would be happy)
Thanks in advance!
Answer by Jaap Kreijkamp · Nov 10, 2010 at 04:31 AM
Use CharacterCollider
Move
or SimpleMove
to push your character by script, for example in C#:
using UnityEngine;
public class Push : MonoBehaviour { public Vector3 speed;
public void OnTriggerStay(Collider col) {
CharacterController ctrl = col.gameObject.GetComponent(typeof(CharacterController)) as CharacterController;
if (ctrl) {
ctrl.SimpleMove(speed);
}
}
}
(just add script to object with trigger collider and set speed
to direction/speed you want your character to move when in the collider).
I have no idea why but it doesn't work for me (only a bunch of errors) :(
Oh can you make it work for Character $$anonymous$$otor ins$$anonymous$$d?