- Home /
space shooter tutorial creating shots problem
hi, im following the tutorial of space shooter, and i have run on a snag in the "creating shots" video. my problem simply is, my bolt will not move when dragged onto the scene. it simply stays there, on the origin point, no matter how many i spawn. here is my code:
using UnityEngine; using System.Collections;
public class Mover1 : MonoBehaviour { private Rigidbody rb;
public float speed;
void Start()
{
rb = GetComponent<Rigidbody>();
rb.velocity = transform.forward * speed;
}
}
now, i know this is not exactly what the speaker has in the video, but i consulted the upgrade guide and this is what i have.
please and thank you, and have a nice day.
try some constant value ins$$anonymous$$d of speed and make sure speed value is not zero in inspector.
Answer by Arkaid · Aug 22, 2016 at 08:53 AM
Don't edit the velocity value directly. Instead use Rigidbody.AddForce with the ForceMode.VelocityChange flag. Also check what's the mass of your object. It might not move if it's too heavy.
Answer by exspearmtl · Sep 17, 2016 at 04:21 PM
question is closed. i deleted rb = GetComponent(); and unity solved the problem for me. my shots now fly to the end of the screen, as shown in the video.