- Home /
Enemy Moving Does Not Work With A Model?
So I wrote my enemy script originally with just a unity Sphere as the place holder of my enemy. I was happy with it, and it worked. I've made my enemy model and implemented it into unity. I attached the same scripts and gave it the same values as the enemy placeholder. When I run the game however, the enemy just sits there and does nothing, but shoot towards my feet when i come into range. Here's my movement code (Keep in mind, I'm making a sidescroller on the x and y axis):
amtToMove = movespeed * Time.deltaTime;
if(forward)
{
transform.Translate(Vector2.right * amtToMove);
}
if(!forward)
{
transform.Translate(Vector2.left * amtToMove);
}
Forward is already set to true, and movespeed is = 5, it's also an Int. The enemy just has a sphere collider right now.
Answer by Berenger · Jun 18, 2012 at 02:50 PM
The animaion's component is attached to the same transform you're trying to move, and it overrides it. Create an empty gameObject, make your character a child of it, remove the scripts that moves the player and add it to that empty game object.
Thank you very much. I didn't know it was such a simple solution.
Your answer
Follow this Question
Related Questions
Enemy moving sideways 1 Answer
A node in a childnode? 1 Answer
Class enemy in javascript help 1 Answer
how to make a basic AI script in a short time 2 Answers
Script crashes Unity 1 Answer