Answer the question
In order to leave comments, you need to log in
How to make the character's speed increase every n seconds?
How to make the character's speed increase every n seconds? I have a cyclist simulator game, and after, for example, 5 seconds, the character’s speed was not 1, as it was originally, but 2.
Code for character movement:
using UnityEngine;
using System.Collections;
public class NewBehaviour : MonoBehaviour
{
public GameObject player;
public int speedRotation = 3;
public int speed = 5;
public int jumpSpeed = 50;
void Start()
{
player = (GameObject)this.gameObject;
}
void Update()
{
{
player.transform.position += (-player.transform.right) * speed * Time.deltaTime;
}
}
}
Answer the question
In order to leave comments, you need to log in
Make all speeds float. Start a timer at startup and add 0.1 to your speed every 0.1 second. After exceeding 2, stop the timer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question