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 09, 2011 at 08:35 AM · bulletmissing-reference

Errors on Bullet script

Hi I have done a script for a bullet by using documentation of unity but I have a couple of errors. Here you have the code:

// - 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);
     SendMessage ("ApplyDamage", 1);
     clone =     Instantiate(explosionPrefab, pos, rot);

     // Destroy the projectile
     Destroy (gameObject);

}

And here you have the errors:

The referenced script on this Behaviour is missing!
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
ColisionBala:OnCollisionEnter(Collision) (at Assets/nuevo/ColisionBala.js:17)

And:

The referenced script on this Behaviour is missing!
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
$:MoveNext() (at Assets/nuevo/EnemyRangedAttack.js:170)

And:

SendMessage ApplyDamage has no receiver!
UnityEngine.Component:SendMessage(String, Object)
ColisionBala:OnCollisionEnter(Collision) (at Assets/nuevo/ColisionBala.js:16)

Anyone can help me? I achieve the explosion but the player don't loose life >__<'

Thanks for all

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 Aldwoni_legacy · May 09, 2011 at 10:27 AM 0
Share

Don't you kill the same thing twice?

avatar image Infinity · May 09, 2011 at 12:24 PM 0
Share

Don't know, can you help me?

1 Reply

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

Answer by Mortennobel · May 09, 2011 at 09:17 AM

Only destroy the gameObject once as the last thing in your script.

Edit: You should also use

collider.gameObject.SendMessage ("ApplyDamage", 1);

instead of just SendMessage, since you want to call ApplyDamage to the player and not the bullet itself. The player also needs a to have a component attached with a function of the signature:

function ApplyDamage(var v : Integer){
}

And the player also need to have the collider object on the same GameObject as the script with the ApplyDamage function.

Comment
Add comment · Show 1 · 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 09, 2011 at 12:27 PM 0
Share

Same problems with this. And when i wrote this post I forgot to write one of the errors (the one regarding to send message)

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

Make a bullet to do damage 1 Answer

Bullet fires before direction change 0 Answers

How do I make a 2d bullet object move towards the players original position when it is spawned? 2 Answers

transform.TransformDirection not working -- WHAT IM MISSISNG? 1 Answer

Predict 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