Answer by urgrandma · Nov 03, 2020 at 04:19 PM
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;
}
}
}
Your answer
Follow this Question
Related Questions
How do I stop multiple spawns? 0 Answers
Networking concept and spawning questions 1 Answer
[C#] Only one instantiate object is working, the rest is not.. Help meee 0 Answers
How to spawn a prefab every 5 second randomly between a set range? 0 Answers
how to Spawn prefab infront off player and destroy it when hr passed it 0 Answers