Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
public float speed = 100f;
public float forwardSpeed = 100f;
public int speedMultiplier = 5;
public Rigidbody rb;
public TextCustomizer customizer;
private bool onGround = true;
void Update()
{
if (Input.GetKey(KeyCode.Space) && onGround == true)
{
rb.AddForce(Vector3.up * speed);
customizer.AddScore(20);
}
if (transform.position.y < -32) // This block
{
customizer.score = 0;
rb.AddForce(Vector3.zero);
Debug.Log("Velocity is: " + rb.velocity);
Debug.Log("Angular velocity is: " + rb.angularVelocity);
transform.Translate(-0.823698401f, -12.3304148f, -206.559509f);
}
rb.AddForce(Vector3.forward * forwardSpeed * speedMultiplier * Time.deltaTime);
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("Ground"))
{
onGround = true;
}
}
void OnCollisionExit(Collision other)
{
if (other.gameObject.CompareTag("Ground"))
{
onGround = false;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... b-addforce