Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CDIEGO · May 09, 2014 at 03:46 AM · 2dturretflip

flip scale of a tank but turret aim wrong

I hope this video help me to explain video ====> http://youtu.be/KaXKDPWcCvo

alt text

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? alt text

tank.png (488 B)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · May 09, 2014 at 03:46 AM 0
Share

Your picture link is broken. Please fix. Plus can you add the code you use for ai$$anonymous$$g?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2D game unity player flip problems 1 Answer

2D mouse/touch controlled turret problems 0 Answers

Reverse 2D ragdoll directon? 1 Answer

2D example: Flip character without moving 0 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges