Question by
Pablio · Jun 11, 2020 at 12:48 AM ·
c#scripting problemspeed
Speed of the script
I can't understand why the Speed stay very fast
Thank you for your attention
public float speed = 1.0f;
float bas = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("s") || Time.time - bas >= 1)
{
transform.position += new Vector3(0, -1, 0);
Debug.Log(transform.position);
if (!DansGrille())
{
Debug.Log("Dehorsbordure");
transform.position += new Vector3(0, 1, 0);
enabled = false;
FindObjectOfType<Spawner>().SpawnCube();
bas = Time.time;
} }
``
Comment
Answer by Thomas-Hawk · Jun 11, 2020 at 11:44 AM
Multiply 1 by Time.deltaTime.
Your script is saying "1 unit per frame" or "1 meter per frame". Which is to 60 meters in 1 second running at 60fps.
I highly recommend running through the basic Unity beginner tutorials before moving forward.
Your answer
Follow this Question
Related Questions
Rotate Player 90 degrees about its Y axis relative to the mouse being dragged between two angles 1 Answer
item not adding to list correctly! 1 Answer
How to add a editing option to variables in a script in Inspector? 0 Answers
I get a "NullReferenceException" when trying to change the text of a UI text box. 1 Answer
C# Script cant find Tagged Object 1 Answer