Hello,
I’m working on a rocket launcher in my platforming game. The way I want it to work is that whenever a rocket is fired it will fly towards a point specified by a crosshair. Currently, the rocket script has a public transform object which is equal to the transform of the crosshair. But it seems like the values of the transform never update, making rockets fly to where the crosshair begins in the scene editor, and not where it currently is. Code:
public Transform crosshair;
public Vector3 mouseCoords;
// Use this for initialization
void Start() {
mouseCoords.Set(crosshair.position.x, crosshair.position.y, 0);
}
// Update is called once per frame
void Update () {
transform.LookAt(mouseCoords);
transform.Translate(Vector3.forward * rocketspeed * Time.deltaTime);
}