Answer the question
In order to leave comments, you need to log in
Why doesn't movement work in the build?
Everything works fine in the unit, but when I create a build, only one script with movement does not work, everything else works. I've looked all over, and there's no answer anywhere.
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Moving : MonoBehaviour
{
public Rigidbody rb;
float maxSpeed = 8;
float staticSpeed = 8;
void Update()
{
if (Input.GetKey(KeyCode.W))
{
rb.AddForce(Vector3.forward);
}
if (Input.GetKey(KeyCode.S))
{
rb.AddForce(Vector3.back);
}
if (Input.GetKey(KeyCode.A))
{
rb.AddForce(Vector3.left);
}
if (Input.GetKey(KeyCode.D))
{
rb.AddForce(Vector3.right);
}
maxSpeed = staticSpeed;
if (rb.velocity.magnitude > maxSpeed)
{
rb.velocity = rb.velocity.normalized * maxSpeed;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question