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 GerardD · Apr 12, 2013 at 09:07 AM · instantiatecollidercollision detectionaddforcerigid body

Collision Detection between instances of a prefab

I am current trying to implement some simple projectiles (fireballs) in my game in Unity. As it currently stands I am creating a rigidbody instance of my fireball prefab before applying a force to it in the direction of my target. A wizard casting a fireball spell essentially:

 Vector3 target = targetWizard.transform.position - staff.position;
 Rigidbody fireball = (Rigidbody)Instantiate(baseFireball, staff.position, staff.rotation);
 fireball.AddForce(target * speed); 

I have two wizards in my scene that can both shoot these fireballs at each other and I have been trying to set up my collision detection logic so account for both these scenarios:

1) Should the two fireballs collide with each other - something happens 2) Should the fireball hit the opposing wizard - something happens

Currently my fireballs both have Rigidbodies and Box Colliders with a simple script attached that has the onCollisionEnter or onTriggerEnter functions with simple debug messages within each.

     void onCollisionEnter(Collision other)
     {
         Debug.Log("Collision");
     }
 
     void onTriggerEnter(Collision other)
     {
         Debug.Log("Trigger");
     }

I have been unable to work out a situation where any of these functions are called on my fireballs.

Presently when they hit each other or a wizard (it has a rigid body and capsule collider) they show that physics are operating on the impact but neither function above is called.

I've tried the scenario where the Is Trigger is checked but this just leads them to pass through everything without no function called either.

I have tried to read other answers and reference material but have met with no success and I am currently at a loss as to why I cannot get this to work.

Comment
Add comment · Show 1
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 whydoidoit · Apr 12, 2013 at 09:42 AM 1
Share

You are calling those functions OnCollisionEnter and OnTriggerEnter right? With capital 'O's

0 Replies

· Add your reply
  • Sort: 

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help On Checking OverLaping in instantiating 0 Answers

Instantiate GameObjects inside a collider 1 Answer

contuouse collision detection malfunction 2 Answers

how to prevent an gameobject of instantiating if theres an collider where it is supposed to collide 1 Answer

Freeze Position + collision? 0 Answers


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