- Home /
flip scale of a tank but turret aim wrong
I hope this video help me to explain video ====> http://youtu.be/KaXKDPWcCvo
for flip I used
//TURRET ROTATION
public class ControladorTorre : MonoBehaviour {
public float VelocidadAngulo = 1f;
void Start () {
}
void FixedUpdate()
{
}
void Update () {
//ROTATION CONTROL
float v = Input.GetAxis ("Vertical");
if(v>0)
{
transform.Rotate(Vector3.back * VelocidadAngulo *Time.deltaTime);
}
else if(v<0)
{
transform.Rotate(Vector3.forward * VelocidadAngulo * Time.deltaTime);
}
//CLAMP ANGLE
transform.localEulerAngles =new Vector3(
transform.localEulerAngles.x,
transform.localEulerAngles.y,
Mathf.Clamp( transform.localEulerAngles.z,40, 105)
);
}
}
//SHOOTING
using UnityEngine;
using System.Collections;
public class Disparo : MonoBehaviour {
public Transform Disparador;//TURRET
public GameObject Bala;//BULLET
public float ShootForce = 100f;
void Start () {
}
void FixedUpdate()
{
if(Input.GetKeyDown(KeyCode.Space))
{
GameObject bala_instancia = Instantiate(Bala, Disparador.transform.position, Disparador.rotation) as GameObject;
bala_instancia.rigidbody2D.AddForce( Disparador.right * ShootForce );
}
}
}
//MOVEMENT CONTROL
public class Movimiento : MonoBehaviour {
public float MaxSpeed = 10f;
public Transform DetectorDeSuelo;//Ground Detector
public bool MirandoDerecha = true; //Facing
public LayerMask MascaraDeDetectorSuelo;
public bool Grounded= false;
void FixedUpdate()
{
Grounded = Physics2D.Linecast (DetectorDeSuelo.position, transform.position, MascaraDeDetectorSuelo);
float h = Input.GetAxis ("Horizontal");
if(h>0)
{
Debug.Log("Derecha");
rigidbody2D.velocity = new Vector2(h*MaxSpeed, rigidbody2D.velocity.y);;
}
else if(h<0)
{
Debug.Log("Izquierda");
rigidbody2D.velocity = new Vector2(h*MaxSpeed, rigidbody2D.velocity.y);
}
if(Input.GetKeyDown(KeyCode.Q))
{
Flip();
}
}
void Flip()
{
MirandoDerecha = !MirandoDerecha;
Vector3 EscalaActual = transform.localScale;
EscalaActual.x *= -1;
transform.localScale = EscalaActual;
}
}
how can I fix the turret aim?
tank.png
(488 B)
Comment
Your picture link is broken. Please fix. Plus can you add the code you use for ai$$anonymous$$g?
Your answer
Follow this Question
Related Questions
2D game unity player flip problems 1 Answer
2D mouse/touch controlled turret problems 0 Answers
Reverse 2D ragdoll directon? 1 Answer