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
1
Question by shadowclasper · Oct 24, 2010 at 08:37 PM · collision

Destroying a Character

I need help adjusting the way two characters using Character Controller and FPS walker work.

I've made it so that they'll register when they collide into one another, they will check what the terrain is like. If certain objects are present, the first one will be destroyed but not the second one. IF they aren't present, the second character will be destroyed, but not the other.

I don't think they're registering each other's presence. Nothing I'm doing seems to get one to destroy the other.

this is the code I'm using:

var hit : RaycastHit;

function OnTriggerEnter(CollisionInfo : Collider){

if (collision info.gameobject.tag == "Samurai"){ if (Physics.Raycast (transform.position, new Vector3(1,0,1), hit, 10) ){ if (hit.collider.gameObject.tag=="Shadow") { Destroy(collisionInfo.gameObject); } else { Destroy (gameObject); } } } }

I think I know PART of the problem, which is I have two objects using CharacterController, and not one object with CharacterController and one with some collider in it, but I have no idea what I'm supposed to do to fix the problem.

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 BinaryCaveman · Oct 24, 2010 at 09:00 PM 0
Share

Could you post the code you are using so we can check if there are problems (and if there are, what they are)? This would make our task much easier, because there are many ways you could complete this task.

avatar image shadowclasper · Oct 24, 2010 at 09:29 PM 0
Share

done, added it. The goal is to make it so that if a wall object is present (one that would simulate there being a shadow) then the samurai character will die by running into the ninja. If there is no wall (tagged Shadow) then the ninja will be the one destroyed.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Adam Rademacher · Oct 24, 2010 at 09:53 PM

First, OnTriggerEnter returns a collider, the collider that entered the trigger. You probably want to use OnCollisionEnter or OnControllerColliderHit.

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 shadowclasper · Oct 24, 2010 at 10:04 PM 0
Share

alrighty, so that would solve the problem of two character's colliding?

avatar image Adam Rademacher · Oct 25, 2010 at 04:30 AM 0
Share

Absolutely. OnTriggerEnter is called when a collider enters another collider that is marked 'trigger' in the inspector. Character controllers are a special type of collider and can't be a trigger, so two hitting each other won't register.

avatar image
1

Answer by shadowclasper · Oct 24, 2010 at 10:45 PM

Okay. I'm simplifying the code to the point where it's just "if ninja touches Samurai, then print 'Hit'" just to test to see if it's actually happening.

I figure the code SHOULD look something like this:

function OnControllerColliderHit(hit:ControllerColliderHit){ 
    if(hit.gameObject.tag=="Samurai"){ 
        print("hit");
        }
    }

It is still not working. Any suggestions?

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Weird collision error when using waypoint script... 1 Answer

Movement around a huge object by avoiding obstacles 1 Answer

[Solved] Is it okay if we change transform.position on a kinematic rigid body which also does not use Gravity? 2 Answers

OnTriggerStay2D with many colliders 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