Quantcast
Channel: Unity3D Student » values
Viewing all articles
Browse latest Browse all 3

Beginner B28 – SendMessage() to Call External Functions

$
0
0

How to use SendMessage() to call functions in scripts attached to other objects.

Code Used (Javascript) – Reactor.js

var downTexture : Texture2D;
  1.  
  2. function React () {
  3.  renderer.material.mainTexture = downTexture;
  4.  yield WaitForSeconds(1);
  5.  gameObject.AddComponent(Rigidbody);
  6. }

Code Used (Javascript) – Switcher.js

function OnCollisionEnter(col : Collision) {
  1.  if(col.gameObject.name == "Switch"){
  2.   gameObject.Find("Block").SendMessage("React");
  3.  }
  4. }

Further Reading


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images