Created
November 10, 2017 01:39
-
-
Save pacoelayudante/1ffd1007fae3a25040deeae2ab3b4c03 to your computer and use it in GitHub Desktop.
Copia del Pin de Construct 2. Toma la posicion, rotacion y/o esacala de otro transform. Para cuando no te sirve o no alcanza hacer que sea relacion hijo-padre
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Para esas veces que poner un objeto como hijo no alcanza o no sirve | |
* | |
* | |
*/ | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Pin : MonoBehaviour { | |
[Header("Quien")] | |
public Transform quien; | |
[Header("Que")] | |
public bool posicion; | |
public bool rotacion, escala; | |
[Header("Como")] | |
public Space como = Space.World; | |
[Header("Cuando")] | |
public bool enFixedUpdate; | |
public bool enUpdate, enLateUpdate; | |
private void FixedUpdate() | |
{ | |
if (enFixedUpdate) Hacer(); | |
} | |
private void Update() | |
{ | |
if (enUpdate) Hacer(); | |
} | |
private void LateUpdate() | |
{ | |
if (enLateUpdate) Hacer(); | |
} | |
// Update is called once per frame | |
void Hacer () { | |
if (quien) | |
{ | |
if (como == Space.Self) | |
{ | |
if (posicion) transform.localPosition = quien.localPosition; | |
if (rotacion) transform.localRotation = quien.localRotation; | |
if (escala) transform.localScale = quien.localScale; | |
} | |
else | |
{ | |
if (posicion) transform.position = quien.position; | |
if (rotacion) transform.rotation = quien.rotation; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment