x


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

more ▼

asked Feb 23 '12 at 11:41 PM

skully42 gravatar image

skully42
21 6 9 10

Can you post the code for your enemy movement and collision? It could be a number of issues depending on your implementation

Feb 24 '12 at 12:08 AM Travis 18

everything is in unity i didnt chnang or write my own script

Feb 24 '12 at 01:36 AM skully42

Well theres one problem

Feb 24 '12 at 01:58 AM Default117

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!

Feb 24 '12 at 05:31 AM Travis 18

do you want the script if so which one

Feb 24 '12 at 03:05 PM skully42
(comments are locked)
10|3000 characters needed characters left

6 answers: sort voted first

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.

more ▼

answered Feb 24 '12 at 03:59 PM

kievar1983 gravatar image

kievar1983
66 10 11 15

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

Feb 24 '12 at 07:20 PM skully42

Well, then you can just move the enemies y position up above the floor, so it doesn't fall through.

Feb 24 '12 at 07:34 PM MithosAnnar

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.

Feb 24 '12 at 07:36 PM kievar1983

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

Feb 25 '12 at 01:35 PM skully42

ok, so copy and paste the 'chase' code underneath this comment.

Feb 25 '12 at 01:43 PM MithosAnnar
(comments are locked)
10|3000 characters needed characters left

http://answers.unity3d.com/questions/229317/enemy-rigidbody-not-responding-to-gravity.html

This link fixed an identical problem for me, in your enemies following script place it right under the "function Update(){", it might solve it for you

more ▼

answered Jan 17 at 11:05 AM

FloshPlosh gravatar image

FloshPlosh
1

(comments are locked)
10|3000 characters needed characters left

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;

}
more ▼

answered Feb 25 '12 at 07:53 PM

MithosAnnar gravatar image

MithosAnnar
299 22 36 41

If I got something wrong or you received an error tell me cause I haven't tested it.

Feb 25 '12 at 08:32 PM MithosAnnar

no errors but i didnt get a change what was it supposed to do

Feb 26 '12 at 12:04 AM skully42

So they still fell through the floor?

Feb 26 '12 at 11:20 AM MithosAnnar

Try putting a box collider on your floor.

Feb 26 '12 at 11:21 AM MithosAnnar

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

Feb 26 '12 at 03:47 PM skully42
(comments are locked)
10|3000 characters needed characters left

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?

more ▼

answered Feb 24 '12 at 12:16 AM

Default117 gravatar image

Default117
346 26 30 33

i tend to find people answer the questions that havent been answered the other one didnt get a answer in a few weeks

Feb 24 '12 at 01:35 AM skully42

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 programming 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.

Feb 24 '12 at 02:04 AM Jason B

so what do you want me to do

Feb 24 '12 at 03:05 PM skully42
(comments are locked)
10|3000 characters needed characters left

:) 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.

more ▼

answered Mar 07 '12 at 12:16 PM

Kergal gravatar image

Kergal
138 3 3 9

i already did that but thanks for the help i guees

Mar 11 '12 at 02:13 AM skully42
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2058
x699
x672
x105
x40

asked: Feb 23 '12 at 11:41 PM

Seen: 1688 times

Last Updated: Jan 17 at 11:05 AM