im making a game in which the player can throw a grenade, but i dont know how or what the code would look like, plz help
I have found an answer to my question, to anyone who would want to do the same thing I’m trying to do
you can use this script found in "instantiating a prefab section of the Unity Manual
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FireProjectile : MonoBehaviour
{
public Rigidbody projectile;
public float speed = 4;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Rigidbody p = Instantiate(projectile, transform.position, transform.rotation);
p.velocity = transform.forward * speed;
}
}
}