Комментарии:
great video brother
ОтветитьFor some reason whenever I try to test it and I jump off my character just falls off.
Ответитьgood
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarController : MonoBehaviour {
// Settings
public float MoveSpeed = 50;
public float MaxSpeed = 15;
public float Drag = 0.98f;
public float SteerAngle = 20;
public float Traction = 1;
// Variables
private Vector3 MoveForce;
// Update is called once per frame
void Update() {
// Moving
MoveForce += transform.forward * MoveSpeed * Input.GetAxis("Vertical") * Time.deltaTime;
transform.position += MoveForce * Time.deltaTime;
// Steering
float steerInput = Input.GetAxis("Horizontal");
transform.Rotate(Vector3.up * steerInput * MoveForce.magnitude * SteerAngle * Time.deltaTime);
// Drag and max speed limit
MoveForce *= Drag;
MoveForce = Vector3.ClampMagnitude(MoveForce, MaxSpeed);
// Traction
Debug.DrawRay(transform.position, MoveForce.normalized * 3);
Debug.DrawRay(transform.position, transform.forward * 3, Color.blue);
MoveForce = Vector3.Lerp(MoveForce.normalized, transform.forward, Traction * Time.deltaTime) * MoveForce.magnitude;
}
}
car script for no reason
does it work with VR?
ОтветитьNOICE
Ответить