- Home /
Creating a spread shot using prefabs
Hi,
I'm currently doing the Space Shooter tutorial and there I've learned how to create a a shot using a prefab called Bolt that contains a Quad called VFX that has the texture for the shot. The shot, when instantiated, has its movement ruled by the Mover script.
I want to expand on this idea creating a spread shot that consists of three shots, one in the middle that should be identical to the example in the tutorial, and two to the sides, one rotated 30 degrees from the middle one and one rotated -30 degrees.
So I created a prefab called SpreadShot with three quads VFX1, VFX2 and VFX3, with their respective rotations already set, so the only thing I need is to make them go forward. But, they are all going forward on the z-axis. This is fine for the middle one, but the side shots should go forward in the direction they are facing instead of forward in the z-axis.
The original Mover script:
using UnityEngine;
using System.Collections;
public class Mover : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
rigidbody.velocity = transform.forward * speed;
}
}
What should I put instead of transform.forward in this case?
post how you instantiate the mover and how you rotate them.
set the correct rotation when you instantiate your prefab and it should work.
Your answer
Follow this Question
Related Questions
OnTriggerEnter Not working in sample project 2 Answers
space shooter tutorial creating shots problem 2 Answers
Space Shooter - NullReferenceException on Scene Reload 0 Answers
Trouble understanding Quaternion.identity in tutorial 1 Answer
Space Shooter Tutorial; Player won't move as shown at 7:05 in the Tutorial Video 3 Answers