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 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 = this.Gameobject;) to another script.

What I have is: var hitPoints : float = 50.0; var sound : AudioClip; var del = this.Gameobject;

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

for sending the message, and:

 public void Medic (float hitPoints) {
     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 this 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 = this.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.

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

Get game component type? 1 Answer

unable to turn enntity on/off with raycast 1 Answer

Making Interstitial appear when the counter reaches a certain number 1 Answer

NullReferenceException error in an array of objects 0 Answers

I found a way to LINK JS AND C# but i have 1 problem 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