- Home /
,How to gradually make my character go faster
As I passed to visual coding in UE4 to unity I dont know a lot so what I want to do is make my 2D endless runner gradually go faster but I dont know how this is my code of the player:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Jugador : MonoBehaviour { public float fuerzaSalto; public GameManager gameManager; int saltosHechos;
int limiteSaltos = 2;
private Rigidbody2D rigidbody2D;
private Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
rigidbody2D = GetComponent<Rigidbody2D>();
saltosHechos = 0;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
if (saltosHechos < limiteSaltos)
{
animator.SetBool("estaSaltando", true);
rigidbody2D.AddForce(new Vector2(0, fuerzaSalto));
saltosHechos++;
{
if (Input.GetMouseButtonDown(0))
{
}
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Suelo")
{
animator.SetBool("estaSaltando", false);
}
if (collision.gameObject.tag == "Obstaculo")
{
gameManager.gameOver = true;
}
if (collision.collider.tag == "Suelo")
{
saltosHechos = 0;
}
}
}//finish
As I passed t visual blueprint in UE4 to unity I dont know a lot so what I want to do is make my 2D endless runner gradually go faster but I dont know how this is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Jugador : MonoBehaviour { public float fuerzaSalto; public GameManager gameManager; int saltosHechos;
int limiteSaltos = 2;
private Rigidbody2D rigidbody2D; private Animator animator; // Start is called before the first frame update void Start() { animator = GetComponent(); rigidbody2D = GetComponent(); saltosHechos = 0;
}
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) if (saltosHechos < limiteSaltos) {
animator.SetBool("estaSaltando", true);
rigidbody2D.AddForce(new Vector2(0, fuerzaSalto));
saltosHechos++;
{
if (Input.GetMouseButtonDown(0))
{
}
}
}
}
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Suelo") { animator.SetBool("estaSaltando", false); }
if (collision.gameObject.tag == "Obstaculo")
{
gameManager.gameOver = true;
}
if (collision.collider.tag == "Suelo")
{
saltosHechos = 0;
}
},As I passed to visual coding in UE4 to unity I dont know a lot so what I want to do is make my 2D endless runner gradually go faster but I dont know how this is my code of the player:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Jugador : MonoBehaviour { public float fuerzaSalto; public GameManager gameManager; int saltosHechos;
int limiteSaltos = 2;
private Rigidbody2D rigidbody2D;
private Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
rigidbody2D = GetComponent<Rigidbody2D>();
saltosHechos = 0;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
if (saltosHechos < limiteSaltos)
{
animator.SetBool("estaSaltando", true);
rigidbody2D.AddForce(new Vector2(0, fuerzaSalto));
saltosHechos++;
{
if (Input.GetMouseButtonDown(0))
{
}
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Suelo")
{
animator.SetBool("estaSaltando", false);
}
if (collision.gameObject.tag == "Obstaculo")
{
gameManager.gameOver = true;
}
if (collision.collider.tag == "Suelo")
{
saltosHechos = 0;
}
}
}//finish
Your answer
Follow this Question
Related Questions
How to change variables inside FindGameObjectsWithTag objects 0 Answers
High score line in a runner ? 0 Answers
How do i make chaser in 2D enless runner? 1 Answer
4 C# errors Endless Runner 0 Answers