Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Dimebag98 · Dec 29, 2014 at 01:28 PM · character controller

Character Controller, and a Enemy.

I have 2 things in my project. A main character, and a enemy. My main have a Character Controller and a Third Person Controller script, a Rigidbody, and no Colliders [character controller has one]. My enemy have a box collider, and a script that say if my main character collide with him, it will do the "hit" animation, and will be "destroyed". Not worked. After a lot of work, I discovered that the supposed problem is the ''Character Controller'' Collider not work too good. What I supposed need is to erase the third person controller, and the character controller, but with myself, the ''Third Person Controller'' works very well with the Main Character movimentation. But I don't want to make a new script to the character move with W,A,S,D, and make the determined animations that I have attached to it. What I can do to my enemy recognize the Collision?

 #pragma strict
 var idling: boolean = true;
 function Start () {
 
 }
 
 function Update () {
 if(idling)animation.Play("Principal");
 }
 function OnCollisionEnter(collision: Collision)
 {
 if(collision.gameObject.tag == "Player")
 {
 animation.Stop();
 idling = false;
 animation.Play("Hit");
 Destroy(gameObject, 2);
 
  }


 }

Sorry for my horrible English, I'm Brazilian. Thnx for help!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mmmpies · Dec 30, 2014 at 10:00 AM 0
Share

Difficult to say from what you've shown us, you're saying the OnCollisionEnter isn't working but that's really all we can see.

So just try a few things.

Try adding a

 Debug.Log("Collided with " + collision.gameObject.tag);

So it reports if it hits anything.

Also try adding a collider to your character.

check the isTrigger isn't ticked on the enemy collider, if it is then either untick or change OnCollisionEnter to OnTriggerEnter.

$$anonymous$$aybe add some screen shots of the Character/Enemy Inspector windows if none of that helps.

PS Your English is pretty good :¬)

avatar image PedroHBorges · Jan 01, 2015 at 04:42 AM 0
Share

I have this:

Collision Bug - http://prntscr.com/5n0mw5 Enemie Config. - http://prntscr.com/5n0n89 Enemie Script - http://prntscr.com/5n0nea Player Config - http://prntscr.com/5n0nn5

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ramp · Jan 01, 2015 at 08:30 AM

hi,

Attached Rigidbody to Enemy.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PedroHBorges · Jan 02, 2015 at 03:59 PM 0
Share

Still not working :-/

http://prntscr.com/5nm4tm

avatar image Mmmpies · Jan 02, 2015 at 04:09 PM 0
Share

Add that Debug.Log statement I suggested, add it before the if statement that checks the Player tag.

Also I'm not familiar with JS as I code in C# but you should be able to use collision.tag rather than collision.gameObject.tag

Try adding both lines but add them before the if statement.

See what results you get in the console.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

in my endless runner game, when i build apk my character glitches..!! does anyone has the solution 0 Answers

CharecterController.Move() ignores parents movement 0 Answers

3D RPG - Player movement - He automatically finds the fastest way and goes around everything. How to limit his movement? 1 Answer

Intermittent bug occurring when re spawning 2 Answers

Character Controller Crouch With transform.localScale Problem. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges