plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using System.Collections;
public class laserReceiver : MonoBehaviour
{
public Color colorNeeded;
public bool connected;
public GameObject objectToConnect;
public string activeFunctionName;
GameObject children;
void Start ()
{
//get the cylinder inside the laser receiver, to set the color needed, so the player can see it
if (transform.childCount > 0) {
children = transform.GetChild (0).gameObject;
children.GetComponent<Renderer> ().material.color = colorNeeded;
}
}
void Update ()
{
//if the laser receiver is reached by the correct laser color, the cylinder rotates
if (connected && children != null) {
children.transform.Rotate (0, 100 * Time.deltaTime, 0);
}
}
//the receiver has been reached by the correct laser color, so call the active function in the object to connect
public void laserConnected (Color col)
{
if (col == colorNeeded) {
connected = true;
if (objectToConnect != null) {
objectToConnect.SendMessage (activeFunctionName, true);
}
}
}
//the laser has been disabled, so disable the object connected
public void laserDisconnected ()
{
connected = false;
if (objectToConnect != null) {
objectToConnect.SendMessage (activeFunctionName, false);
}
}
}