- Home /
In the space shooter tutorial on the "creating shots" the bolt won't move
Hi im new to Unity and C#, and while doing the tutorial for the space shooter i got stucked beacuse on the las par of the session "creatin shots" the shots wont move and i don't know why, i have the same code on the script.
Here is the code:
using UnityEngine;
using System.Collections;
public class Mover : MonoBehaviour
{
public float speed;
void start()
{
GetComponent<Rigidbody>().velocity = transform.forward * speed;
}
}
Any help will be really apreciated.
I have the same exact problem with the bolt game object. I have tried to use the solutions given here but they aren't working either
One thing I noticed on this is that the axes of the bolt seem to be rotated 90 degrees about X after creating and rotating the Quad, whereas in the tutorial video, his axes remain in the same orientation as everything else. This meant that I didn't need to reorient the collider around my bolt; does this also mean that the transform.forward command will send the beam in the wrong direction (ie down ins$$anonymous$$d of forward)?
I'm using Unity 5 on Windows.
it should be like this
...... public float speed; private Rigidbody rb: void start() { rb=GetComponent();
rb.velocity=tranform.forward*speed: }
Answer by nuubarak · May 15, 2016 at 03:01 PM
void start()
{
GetComponent<Rigidbody>().velocity = transform.forward * speed;
}
Change to
void Start()
{
GetComponent<Rigidbody>().velocity = transform.forward * speed;
}
Good eye! that happened to me during the tutorials and it took me a $$anonymous$$ute to figure out that I had lowercase start() ins$$anonymous$$d of Start()
Answer by SlowestChunk · Jul 19, 2015 at 06:53 AM
I'm also very new to Unity. I've made my own solution, try this, it worked for me:
public float speed;
void Start ()
{
Rigidbody rb = (Rigidbody)GetComponent(typeof(Rigidbody));
Vector3 movement = new Vector3 (0.0f, 0.0f, 1.0f);
GetComponent<Rigidbody>().velocity = movement * speed;
}
}
Answer by SlowestChunk · Jul 19, 2015 at 01:23 AM
this worked for me:
public float speed;
void Start ()
{
Rigidbody rb = (Rigidbody)GetComponent(typeof(Rigidbody));
Vector3 movement = new Vector3 (0.0f, 0.0f, 1.0f);
GetComponent<Rigidbody>().velocity = movement * speed;
}
}
then you get the attribute "Speed" in the "Player" Object, in the "Script Inspector" Tab. I've set the value for speed to 10.
You can take the same code for the movement of the hazards, setting the speed on -4 or as you like.
Hope this helps!
Answer by chetan.bhale · Jul 10, 2015 at 08:34 AM
public float speed;
void Start ()
{
Rigidbody rb = (Rigidbody)GetComponent(typeof(Rigidbody));
rb.velocity = transform.forward * speed;
}enter code here
Answer by chetan.bhale · Jul 10, 2015 at 08:34 AM
Same i tried but not wroking...
Try this.....`public float speed;
void Start ()
{
Rigidbody rb = (Rigidbody)GetComponent(typeof(Rigidbody));
rb.velocity = transform.forward * speed;
}`
Your answer
![](https://koobas.hobune.stream/wayback/20220613200908im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Creating a spread shot using prefabs 0 Answers
How do i change controller from keyboard to mouse?? 1 Answer
How to keep player in bounds? 1 Answer