Hi
I use sphere Collider (trigger) for my enemy to make the scene move when the player collide with enemy. (game over scene)
but the problem is, i use this script for make my enemy just walk in axis x :
if (controller != null && controller.enabled) {
tr.position = position3D;
deltaPosition.y = 0;
deltaPosition.z = 0;
controller.Move(deltaPosition);
when i play, it doesn’t work, my enemy just walking in place
pls help me. thx
Didn’t you get this to work a few days ago?
i have changed Move method in Ai base ,
protected void Move (Vector3 position3D, Vector3 deltaPosition) {
bool positionDirty = false;
if (controller != null && controller.enabled) {
// Use CharacterController
tr.position = position3D;
deltaPosition.y = 0;
deltaPosition.z = 0;
controller.Move(deltaPosition);
// Grab the position after the movement to be able to take physics into account
// TODO: Add this into the clampedPosition calculation below to make RVO better respo…
the script works if i didn’t use “Sphere Collider” .
but i have to used it to move to another scene
what should i do ?
i use this script for make Game Over scene, when Player collide with Enemy trigger
Are you using a SphereCollider as well as a character controller?
Or more importantly have you attached a rigidbody as well?
You should not use a rigidbody as well as a character controller. You should only use one of them.
can i use characterController to move to another scene?
Yes, CharacterControllers are detected by triggers. If that’s what you mean.
I dont know why my npc “fly” when i use CharacterController ?
and not move to another scene
but when i use Collider it worked, and move to another scene
you can check here : https://drive.google.com/file/d/0B_higDZ_FdFNc0VFbFZ1dERJZVU/view
yes,i use charactercontroller because Move method in Ai base
no, i didn’t use rigidbody.
Is your sphere collider attached to the player or the other object?
I use sphere collider only for Enemy
but for player i use charactercontroller
Ok. If you need to detect OnTriggerEnter you need to use a Rigidbody (for the enemy), not a CharacterController
Note that your code for deltaPosition can just be moved outside that IF statement to work with any movement method, not just a CharacterController.