i am making a crouching(more like sliding)script for my FPS, and there is an error. what is wrong?(the error is "Argument 1: cannot convert from ‘UnityEngine.Vector3’ to ‘float’ ") also if i delete “transform.forward” it seems to work, but it only sets a force in one direction.
using UnityEngine;
public class crouch : MonoBehaviour
{
public CharacterController player;
public Rigidbody rb;
public float boost = 120f;
void Start()
{
player = gameObject.GetComponent<CharacterController>();
rb = gameObject.GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetButton("left shift"))
{
player.height = 0.2f;
player.center = new Vector3(0f, 0.5f, 0f);
rb.velocity = new Vector3(transform.forward * boost * Time.deltaTime, rb.velocity.y, rb.velocity.z);
}
else
{
player.height = 2.1f;
player.center = new Vector3(0f, 0f, 0f);
rb.velocity = new Vector3(0f, 0f, 0f);
}
}
}.
the peticular line of code that has the error is:
rb.velocity = new Vector3(transform.forward * boost * Time.deltaTime, rb.velocity.y, rb.velocity.z);