Category Archive for "UnityCode"

Objeto que órbita alrededor de otro

2 marzo, 2015
Carlos Alberto Ramirez

var target : Transform; var distance = 10.0; var xSpeed = 250.0; var ySpeed = 120.0; var yMinLimit = -20; var yMaxLimit = 80; private var x = 0.0; private var y = 0.0; @script AddComponentMenu(“Camera-Control/Mouse Orbit”) function Start ()…

Read More

Múltiple Waypoints

2 marzo, 2015
Carlos Alberto Ramirez

var waypoint:Transform[]; var speed : float= 20; private var currentWaypoint:int; var loop :boolean=true; function Awake() { waypoint[0]=transform; } function Update () { if(currentWaypoint < waypoint.length){ var target:Vector3 = waypoint[currentWaypoint].position; var moveDirection:Vector3= target – transform.position; var velocity = rigidbody.velocity; if(moveDirection.magnitude <…

Read More

Movimiento Simple

2 marzo, 2015
Carlos Alberto Ramirez

var velocidad= 3.0;//creamos una variable que es la velocidad. var velocidadRotacion= 3.0; //velocidad de rotacion del objeto. function Update () { var controller:CharacterController=GetComponent(CharacterController); //rotar en el eje y transform.Rotate(0, Input.GetAxis(“Horizontal”)*velocidadRotacion, 0); //moverse para atras/retroceder var retrocede = transform.TransformDirection(Vector3.forward); var velocidadGiro…

Read More

Movimiento 3D con salto

2 marzo, 2015
Carlos Alberto Ramirez

var speed : float = 6.0; var jumpSpeed : float = 8.0; var gravity : float = 20.0; private var moveDirection : Vector3 = Vector3.zero; function Update() { var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) { // We are…

Read More

Movimiento 2D

2 marzo, 2015
Carlos Alberto Ramirez

#pragma strict var velocidad:float = 6.0; var velocidadSalto:float = 8.0; var gravedad:float = 20.0; private var moverDireccion:Vector3 = Vector3.zero; function Update () { var controlador:CharacterController = GetComponent(CharacterController); if(controlador.isGrounded) { moverDireccion = Vector3(0,0,Input.GetAxis(“Horizontal”)); moverDireccion *=velocidad; if(moverDireccion.sqrMagnitude>0.01) transform.rotation=Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(moverDireccio n),1); if(Input.GetButton(“Jump”)) { moverDireccion.y…

Read More

Mover objetos con GUI

2 marzo, 2015
Carlos Alberto Ramirez

Mover Objetos con GUI. var objeto:Transform; function OnMouseOver() { objeto.transform.Translate(Vector3.forward * Time.deltaTime); }

Read More

Manejar personaje por medio de controles visuales

2 marzo, 2015
Carlos Alberto Ramirez

var model : GameObject; function OnGUI () { //background box GUI.Box (Rect (10,130,100,90), “Controls”); //Make first button if (GUI.Button (Rect(20,160,80,20), “Arm”)){ model.animation.Play(“raise arms”, PlayMode.StopAll); } //Make second button if (GUI.Button (Rect(20,190,80,20), “Neck”)){ model.animation.Play(“raise neck”, PlayMode.StopAll); } }

Read More

Arrastrar cuerpo rigido

2 marzo, 2015
Carlos Alberto Ramirez

var spring = 50.0; var damper = 5.0; var drag = 10.0; var angularDrag = 5.0; var distance = 0.2; var attachToCenterOfMass = false; private var springJoint : SpringJoint; function Update () { // Make sure the user pressed the…

Read More

Disparo simple

2 marzo, 2015
Carlos Alberto Ramirez

#pragma strict var disparo:Transform; function Update () { if(Input.GetButtonDown(“Fire1”)) { var bala = Instantiate(disparo, GameObject.Find(“spawnPoint”).transform.position, Quaternion.identity); bala.rigidbody.AddForce(transform.forward * 2000); animation.CrossFade (“shoot”); } }

Read More

Cambiar el cursor

2 marzo, 2015
Carlos Alberto Ramirez

var cursorImage : Texture; function Start() { Screen.showCursor = false; } function OnGUI() { var mousePos : Vector3 = Input.mousePosition; var pos : Rect = Rect(mousePos.x,Screen.height – mousePos.y,cursorImage.width,cursorImage.height); GUI.Label(pos,cursorImage); }

Read More