Quantcast
Channel: Latest Questions by Caelorum
Viewing all articles
Browse latest Browse all 14

Why is this script not working? (SendMessage)

$
0
0
I have two scripts. One on a wall, another on a ball. I'm trying to access a void from one script, in a different script. Here is the script with the function: public void ResetBall () { var rigY = rigidbody2D.velocity.y; var rigX = rigidbody2D.velocity.x; var traY = transform.position.y; var traX = transform.position.x; rigY = 0f; rigX = 0f; traY = 0f; traX = 0f; Invoke("goBall", 0.5f); } And here is the script trying to access it: void OnTriggerEnter2D (Collider2D hitInfo) { if (hitInfo.name == "Ball") { var wallName = transform.name; gameMan.Score (wallName); hitInfo.gameObject.SendMessage ("ResetBall"); } } Not going to lie this is all pretty advanced for me, but according to the video i'm watching (who is using javascript), the hitInfo should be able to send a message into the ball, because the ball IS "hitInfo" technically. All I end up getting are warnings saying that rigy/x, and tray/x are not being used. And the ResetBall function doesn't go through.

Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>