- Home /
Problems with enemies
Hey guys i need help. I am making a game where a robot chases the player(you) and tries to kill it and you kill them like a zombie game. So here is the problem the robot in unity are not realy solid. They can walk on the floor but they go through walls, when they walk helf of there body is in the ground, and somehow they can fly when i am on a object. If you can help me with any of these problems that would be great. Thanks
Can you post the code for your enemy movement and collision? It could be a number of issues depending on your implementation
everything is in unity i didnt chnang or write my own script
Oh okay. Given that information, I quantum leaped into your body, assessed the situation, performed a good deed and leaped back into my own. I can tell you that everything is working as it should--robots are supposed to sink into the ground and be non-solid by design (as of Unity 2.6). Good job!
Answer by kievar1983 · Feb 24, 2012 at 03:59 PM
hey skully42, seems like a few people are berating you on here. to answer your what do you want me to do. refine your question.. what have you tried? have you coded any scripts? if so what are the scripts? are you attempting to use collision? was the enemy made in a software application such as 3ds max or maya? if so did you put a mesh collider on it?
these things help us help you. telling us everything you've done will help us find a quick solution to your issue.
from what i have read it sounds like you have a enemy that has no rigid body or box collider on it so it doesn't do any collision detection.
i didnt change or rewrite a script i used the enemy from unity and it can walk on the floor but half or its body is in the ground and i tried putting a collider and a rigidbody and it just falls through the floor i have no idea what to do now i am new to this if you have any questions just ask and i will get back to u as soon as possible
Well, then you can just move the enemies y position up above the floor, so it doesn't fall through.
agreed with mithos, just move the enemy up until it is above the ground then it shouldn't fall through. i usually set the Y to like 1.5 or 2 and let gravity bring it to the ground, if there isn't gravity then i would manually position it.
maybe i wasnt clear and i am srry for that they dont fall through the floor but as the robots start to chase me half of their body is in the floor
ok, so copy and paste the 'chase' code underneath this comment.
Answer by Default117 · Feb 24, 2012 at 12:16 AM
http://answers.unity3d.com/questions/206576/enemy-problem.html
http://answers.unity3d.com/questions/211889/enemy-help.html
http://answers.unity3d.com/questions/220382/solid-enemy-help.html
Maybe stick to just asking the question once and revisiting it? Plenty of people have offered advice already, maybe you should look more into that before asking again and again?
i tend to find people answer the questions that havent been answered the other one didnt get a answer in a few weeks
To be fair, that's because it's a vague question that exhibits no knowledge of game design, no knowledge of Unity, and no use on your part of the Unity manual, and so the answer required to satisfy your needs would end up spanning across a small novel. You need to learn to write your own scripts, first off. Saying "Hey guys there's a problem with a script I didn't write because I have no program$$anonymous$$g knowledge" is pointless, because even if we gave you code to fix it, you would learn virtually nothing, thus you'll be back here every single time you have a basic question. Unity is not a game engine where you can "click together" a game (or even a working demonstration) without any technical knowledge whatsoever, and too many people come here to learn that the hard way.
Answer by MithosAnnar · Feb 25, 2012 at 07:53 PM
Ok, not to fear there skully. And don't worry about the format its fine.
Attach this script to your robots:
chase.js:
var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3;
var myTransform : Transform;
function Awake () {
myTransform = transform;
}
function Start () {
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
If I got something wrong or you received an error tell me cause I haven't tested it.
no errors but i didnt get a change what was it supposed to do
no no no they dont fall through the floor its just half of their body ends up going into the floor while it chases me
Answer by Kergal · Mar 07, 2012 at 12:16 PM
:) did you adjust the character collider ? - on default it is usually not set to fit your character. Click on your Enemy in the hierachy - and look up its character collider - set the y value a bit higher.. and make sure most of your character is surrounded. That should stop your enemies from walking through the floor and foor the rest... idk :)
Cheers Kerg.
Answer by Kergal · Mar 07, 2012 at 10:10 AM
just adjust your enemies CharacterController. it is that green wireframe thing - it defines the whether your characters sink into ground or not. Click your enemy - look up the CharacterController adjust the y value (usually put in a higher number) push play - see if its alright - if not .. play with the numbers a bit. Should do the trick. or even better ;) write a script to do it for you ;) something like.... http://unity3d.com/support/documentation/ScriptReference/CharacterController-height.html instead of hardcoding you could use a public variable --> then you can play with the value in the inspector. and maybe you want to look up http://unity3d.com/support/documentation/ScriptReference/CharacterController-radius.html --> define the radius http://unity3d.com/support/documentation/ScriptReference/CharacterController-center.html --> my personal favorite. creates a dependency between the transform and the controller.
I hope 90 % of what I wrote is alright. I am a newbie as well ;)
Cheers Kergal
thanks for you help but i know a little scripting but i dont think i cant write a realy long script and i trted moving the charactercontroller and it didnt work any other ideas would be great
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Problem with enemy health. 1 Answer
Solid enemy help 1 Answer
Enemy Spawning Place 0 Answers
Enemy Death and Killing Script 3 Answers