Answer the question
In order to leave comments, you need to log in
How to bind RigidBody to a script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rocket : MonoBehaviour
{
Rigidbody rigidBody;
void Start()
{
rigidBody = GetComponent<Rigidbody>();
}
void Update()
{
processInput();
}
void processInput()
{
if(Input.GetKey(KeyCode.Space))
{
rigidBody.AddRelativeForce(Vector3.up);
print("пробел");
}
if(Input.GetKey(KeyCode.A))
{
print("Поворот влево");
}
else if(Input.GetKey(KeyCode.D))
{
print("Поворот вправо");
}
}
}
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