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 Infinity · May 08, 2011 at 07:12 PM · bulletmissing-reference

Make a bullet to do damage

Hi, I have done a cannon bullet and I have seen this script here on unity

// A grenade // - instantiates a explosion prefab when hitting a surface // - then destroys itself

var explosionPrefab : Transform;

function OnCollisionEnter(collision : Collision) { // Rotate the object so that the y-axis faces along the normal of the surface var contact : ContactPoint = collision.contacts[0]; var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal); var pos : Vector3 = contact.point;

     // Kill ourselves
     Destroy(gameObject);

     clone =     Instantiate(explosionPrefab, pos, rot);

     // Destroy the projectile
     Destroy (gameObject);

}

Now I have a couple of problems, first of all, everytime my bullet explodes I found this message on the console:

The referenced script on this Behaviour is missing! UnityEngine.Object:Instantiate(Object, Vector3, QUaternion)

And the second problem I have it's that I want this bullet to hurt objects tagged as "Player" by using "function ApplyDamage (damage : int)" that Players have.

Know that this it's very silly and fool, but I'm a little bit noobish.

Lot of thanks for all

Comment
Add comment · Show 3
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 FLASHDENMARK · May 08, 2011 at 07:20 PM 1
Share

There is no such thing as silly and foolish questions, only silly and foolish answers. Remember we have all been there.

avatar image Infinity · May 08, 2011 at 07:24 PM 0
Share

Thanks for the comprehension

avatar image Infinity · May 08, 2011 at 08:28 PM 0
Share

In any case you can help me on this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Dave 11 · May 08, 2011 at 09:36 PM

The referenced script on this Behaviour is missing! UnityEngine.Object:Instantiate(Object, Vector3, QUaternion)

For this, you'll need to add your prefab to the script by dragging it to the script component on the gameObject.

For the damage part: Add a variable named hitpoints to your player gameObject, then make it decrease when the bullet collides with the player.

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 Infinity · May 08, 2011 at 09:43 PM 0
Share

$$anonymous$$y player have hitpoints, but I don't know how to make the bullet collision with player active the "function ApplyDamage (damage : int)" on the player

avatar image Dave 11 · May 08, 2011 at 09:49 PM 0
Share

Use this function to call a sendmessage http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html http://unity3d.com/support/documentation/ScriptReference/Component.Send$$anonymous$$essage.html

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

Errors on Bullet script 1 Answer

OnCollisonEnter never being called 1 Answer

Shooting style like enter the dungeon 0 Answers

Help with bullet spread pattern 1 Answer

When player shoot a butllet, the bullet does not go straight at what the player is facing. 2 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