Hi! , Im trying to get jumps like the game "the impossible game":
https://www.youtube.com/watch?v=vW8nXTzroos
Well, I wrote the essential, some rigidbody2D.AddForce to make the jump etc, the PROBLEM is that when I click ( It add the force in Y) it add more force to X, and obviously I don't want that, I want to keep the velocity in the X.
And sorry for my english ^^ Ohh and if someone knows how to do these types of jumps like the video I posted, tell me please! I tried to change the gravity but I still without get this type of jumps hehe.
Here is the code, hope you can help me guys!:
using UnityEngine;
using System.Collections;
public class controladorPersonaje : MonoBehaviour {
public float fuerzaSalto = 100f;
public float fuerzaCorrer = 100f;
public bool enSuelo = true;
public bool enSuelo1 = true;
public bool enSuelo2 = true;
public bool enSuelo3 = true;
public bool enSuelo4 = true;
public Transform comprobadorSuelo;
float comprobadorRadio = 0.07f;
public Transform comprobadorSuelo1;
float comprobadorRadio1 = 0.07f;
public Transform comprobadorSuelo2;
float comprobadorRadio2 = 0.07f;
public Transform comprobadorSuelo3;
float comprobadorRadio3= 0.07f;
public Transform comprobadorSuelo4;
float comprobadorRadio4 = 0.07f;
public LayerMask mascaraSuelo;
private Animator animator;
void Awake(){
animator = GetComponent ();
}
// Use this for initialization
void Start () {
}
void FixedUpdate(){
enSuelo = Physics2D.OverlapCircle (comprobadorSuelo.position, comprobadorRadio, mascaraSuelo);
animator.SetBool ("isGrounded", enSuelo);
enSuelo1 = Physics2D.OverlapCircle (comprobadorSuelo1.position, comprobadorRadio1, mascaraSuelo);
animator.SetBool ("isGrounded", enSuelo1);
enSuelo2 = Physics2D.OverlapCircle (comprobadorSuelo2.position, comprobadorRadio2, mascaraSuelo);
animator.SetBool ("isGrounded", enSuelo2);
enSuelo3 = Physics2D.OverlapCircle (comprobadorSuelo3.position, comprobadorRadio3, mascaraSuelo);
animator.SetBool ("isGrounded", enSuelo3);
enSuelo4 = Physics2D.OverlapCircle (comprobadorSuelo4.position, comprobadorRadio4, mascaraSuelo);
animator.SetBool ("isGrounded", enSuelo4);
rigidbody2D.AddForce (new Vector2 (fuerzaCorrer, 0));
if (enSuelo && Input.GetMouseButton (0) || enSuelo1 && Input.GetMouseButton (0)|| enSuelo2 && Input.GetMouseButton (0)|| enSuelo3 && Input.GetMouseButton (0)|| enSuelo4 && Input.GetMouseButton (0)) {
rigidbody2D.AddForce (new Vector2 (0, fuerzaSalto));
//transform.Rotate(new Vector3(0,0,70));
//transform.Rotate(0, Time.deltaTime * 30, 0, Space.Self);
}
}
// Update is called once per frame
void Update ()
{
}
}
↧