Enemy collisions - do they use a character controller?

Hey everyone, I’m wanting to get my enemies to bump into objects when they move and slide around them much like the main player does due to the CharacterController

Shouls I be putting character controllers onto the enemies as well, or is there a better way that gives a similar result?

thanks in advance for your help :slight_smile:

Also as an extra bit of information, this is for something I’d eventually want to be an iphone game :slight_smile:

Ok one last try to see if anyone answers :slight_smile:

I’m now using a charactercollider on the enemies which all seems to work ok, however I’m struggling to use collider.move to get them to walk directly at the players position

I have the enemy rotating to look at the player which works, and then I can translate on vector3.forward to get them always moving at the player - however if i use a .forward to .move the controller it just move the enemy directly to the right and off the screen

Can anyone please help? :slight_smile:

A little script example of what you have so far would be useful, but I can think of a couple of pointers to help you right now based on what you’ve written.

You say you’re using the Vector3.forward, this will give you a world based vector, rather than one that is relative to the player. You should use the enemies forward vector (gameObject.transform.forward). This will give you the forward facing vector of the enemy.

Also make sure you multiply the speed of the character by Time.delta time so you have framerate independent speed of the character. I’m not sure if this is one of the issues you’re having, but it sounds like it where you say

:slight_smile:

I finally sorted it out:

			transform.LookAt(target.transform.position);
			
			Vector3 direction = transform.TransformDirection(Vector3.forward);
			controller.Move(direction * moveSpeed * Time.deltaTime);

So I rotate the gameobject so its always facing the player (I do this because I have a child object with the muzzle location so it shoots towards the player). Then just the simple controller move

I tried this same thing earlier and it didn’t work which ended up with me trying out lots of different things, and now for some reason it does so I must have changed something by accident… euuurgh :slight_smile: