• 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 /
This question was closed Nov 17, 2014 at 04:19 AM by robertbu for the following reason:

Duplicate Question

avatar image
0
Question by SuzyKay · Nov 17, 2014 at 04:19 AM · javascriptscript error

'other' is not a member of 'Object'?

Hi Guys, so I have this script I tried from this tutorial: https://www.youtube.com/watch?v=0SFlKkfbHLQ

and I copied the exact same thing, yet I am getting an error i am not sure of means as I am still a beginner.

 #pragma strict
 
 var damage = 10;
 
 function OnCollisionEnter (collisionInfo) 
 {
     //when there is a collision, it will send a message and look for the ApplyDamage function
     collisionInfo.other.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
 }    //when bullet hits, its going to tell the healthbar to decrease life

I have applied the script onto my bullet and everything but unity keeps telling me that 'other' is not a member of 'object'...I cant figure out whats wrong as the script is the exact same as the one in the tutorial. Any help would be appreciate!

Comment
Add comment · Show 5
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 Kiwasi · Nov 17, 2014 at 04:28 AM 0
Share

Or use C#. C# doesn't break like this.

avatar image SuzyKay · Nov 17, 2014 at 04:47 AM 0
Share

@robertbu: Thanks! that got rid of that error, but now it says: "BCWOO12: WARNING: "UnityEngine.Collision.other' is obsolete. Please use Collision.rigidbody, Collision.transform or Collision.collider ins$$anonymous$$d"

@Bored$$anonymous$$ormon: I am learning Javascript for class, so Im stuck with this atm

avatar image Kiwasi · Nov 17, 2014 at 04:58 AM 0
Share

The error message tells you exactly what to do. Pick the statement as appropriate. In your case I would go with

 collisionInfo.rigidbody.Send$$anonymous$$essage(...);

But without seeing your exact set up its hard to tell if it actually matters which one you pick.

avatar image MD_Reptile · Nov 17, 2014 at 05:02 AM 1
Share

If your learning regular JavaScript for a class, the unityscript that unity has works differently. Just incase you didn't know!

avatar image SuzyKay · Nov 17, 2014 at 05:21 AM 0
Share

@Bored$$anonymous$$ormon: Here is the other related Health script as the other is damage: (Unless you need more info)

 #pragma strict
 
 var maximumHealth = 100.0;
 var health = 100.0;
 var healthGUI : GUITexture;
 
 private var healthGUIWidth = 0.0;
 private var gotHitTimer = -1.0; 
 
 function Awake ()
 {
     healthGUIWidth = healthGUI.pixelInset.width;
 }
 
 function ApplyDamage (damage : float)
 {
     if(health < 0.0) //if not, gonna do something else
         return;
         
         health -= damage;//health $$anonymous$$us
         
         if(health < 0.0)
             Die();
 }
 
 function Die()//stops controlling character
 {
     var components : Component[]= GetComponentsInChildren($$anonymous$$onoBehaviour);
     for (var b in components) 
         {
             var p : $$anonymous$$onoBehaviour = b as $$anonymous$$onoBehaviour;
             if (p)
                 p.enabled = false;
         }
 }
 
 function LateUpdate ()//constantly updating GUI
 {
     UpdateGUI();
 }
 
 function UpdateGUI()
 {
     var healthFraction = $$anonymous$$athf.Clamp01(health / maximumHealth);
     healthGUI.pixelInset.x$$anonymous$$ax = healthGUI.pixelInset.x$$anonymous$$in + healthGUIWidth * healthFraction;
 }

@$$anonymous$$D_Reptile: Yea, Im learning Unity Javascript.

1 Reply

  • Sort: 
avatar image
0

Answer by robertbu · Nov 17, 2014 at 04:20 AM

You need to type your parameter. Line 5 should be:

  function OnCollisionEnter (collisionInfo : Collision)

http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

my gui text write over an over in a row 1 Answer

How can stop the repeat random number (Random.Range) 2 Answers

Playerprefs not saving 1 Answer

Compare transform.localscale 1 Answer

audio not playing when i destroy gameobject or setactive to false,audio not playing when i destroy gameobject or setactive into false 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