x


Collision - 2 Objects

I've 2 characters, they both have characterControllers and Capsule collider(with same radius and height - to fit the characterController collider style), I want to check if there's a collision between them, and if there's so the second character will play an animation too.(which is attack animation)

On my main hero :

function OnControllerColliderHit(hit : ControllerColliderHit)
{
        if(hit.collider.name.Contains("Lv"))
        {
                animation.CrossFade("attack1");
        }
}

On the monster :

function OnCollisionEnter(hit : Collision)
{
        if(hit.collider.tag == "Player")
        {
                animation.CrossFade("attack1");
        }
}
more ▼

asked Jun 24, 2010 at 01:23 PM

AnaRhisT gravatar image

AnaRhisT
965 88 61 74

Mike, instead of editing lol, answer me! :<

Jun 24, 2010 at 01:50 PM AnaRhisT

please provide more information. does it have an error. does unity call it or not? ...

Jun 24, 2010 at 02:14 PM Ashkan_gc

Now, I put function OnControllerColliderHit(hit : ControllerColliderHit) and it does collide, but only when it moves.. I don't want it to collide just when it moves, I want a fast collision when there's a collision. which means - when the player hits the enemy when it's on move so they both will use animation.

Jun 24, 2010 at 02:47 PM AnaRhisT

There are almost identacle threads. Search before you post!!!

Jun 24, 2010 at 04:48 PM Pirate___man

Which one are you about? Also, almost isn't enough.

Jun 24, 2010 at 05:09 PM AnaRhisT
show all comments (comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

it seems that the problem is in another place like the name of the collider or the tag of the player. to make sure that the function is called use print and print the name of other collider and ... in less than a few month we will have a debugger wich will solve all problems like this easier. :) be aware that names are case sensitive.

more ▼

answered Jun 24, 2010 at 02:10 PM

Ashkan_gc gravatar image

Ashkan_gc
10.1k 76 91 160

Yeah I know, I'll put some debugs now, and what do u mean debuggers which will solve all problems? O_O

Jun 24, 2010 at 02:13 PM AnaRhisT
(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:

x6625
x4156
x1153

asked: Jun 24, 2010 at 01:23 PM

Seen: 2185 times

Last Updated: Jun 24, 2010 at 01:34 PM