• 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 ik_jolan · May 11, 2014 at 10:51 AM · c#errorgameobjectsend message

send message object variable

Hello, I am trying to send a variable with an object (var del = t$$anonymous$$s.Gameobject;) to another script.

What I have is: var $$anonymous$$tPoints : float = 50.0; var sound : AudioClip; var del = t$$anonymous$$s.Gameobject;

 function OnTriggerEnter (other : Collider) { 
     if (other.CompareTag ("Player")){
         other.SendMessageUpwards("Medic", $$anonymous$$tPoints, SendMessageOptions.DontRequireReceiver);
         other.SendMessageUpwards("Del", del, SendMessageOptions.DontRequireReceiver);
         AudioSource.PlayClipAtPoint(sound, transform.position);
         //Destroy(gameObject);
         //PhotonNetwork.Destroy(t$$anonymous$$s.gameobject);
     }    
 }

for sending the message, and:

 public void Medic (float $$anonymous$$tPoints) {
     currentHp+=150;
         
  if (currentHp > 250.0)
     currentHp=250;
     //PhotonNetwork.Destroy(other);
 
 }
     public void Del (GameObject del) {
     PhotonNetwork.Destroy(del);
 }

for receiving The problem is I get t$$anonymous$$s error when running the game:

Failed to call function Del of class PlayerDamage Calling function Del with no parameters but the function requires 1. UnityEngine.Component:SendMessageUpwards(String, Object, SendMessageOptions) Medic:OnTriggerEnter(Collider) (at Assets/Resources/NewScripts/Medic.js:8)

You probably already saw the first script is js and the second c# public void Medic does work correctly, only the Del void gets an error

It would be great if someone could help me

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Maerig · May 12, 2014 at 01:55 AM

GameObject : The GameObject class.

gameObject : The gameObject your script is attached to.

You have to use

 var del = t$$anonymous$$s.gameobject;
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.

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

error CS0118: `New_Career.Fame' is a `field' but a `type' was expected 1 Answer

Cannot change method name in a class. 1 Answer

Distribute terrain in zones 3 Answers

Disabling A Script on a GameObject From a Different Script 2 Answers

Multiple Cars not working 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