So I am making a racing game where you control a ragdoll in a car and i have a movement script,
but i'm quite new to unity and im not sure how to make it so you can only control the car while the ragdoll is inside. If it helps I am using C# and here is the movement script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
private float speed = 10.0f;
private float turnSpeed = 25.0f;
private float horizontalInput;
private float forwardInput;
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
forwardInput = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);
transform.Rotate(Vector3.up, turnSpeed * horizontalInput * Time.deltaTime);
}
}
↧