Question by
astroboyr · May 18, 2019 at 06:22 AM ·
rotationinstantiaterotateinstantiate prefab
Rotation not working properly when ,Script rotation not working when instansiating.
Hi, so I am making a game, it is instantiating fuel prefabs. Before, when I drag it out, as a normal prefab, it spins correctly, side to side like --- not |. But when the script instantiates it, it breaks and spins up and down. Please help. Here is some code. This is my first time posting on the community, so sorry if I didn't include enough details. using UnityEngine;
public class FuelRotate : MonoBehaviour { public Transform fuelObject; void FixedUpdate(){
fuelObject.transform.Rotate(new Vector3(0,0,fuelObject.transform.rotation.y+5));
}
} and
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class MakeFuel : MonoBehaviour {
public Transform player;
public GameObject fuel;
public float spawnRate;
public float z;
void Start(){
InvokeRepeating("makeFuel",1f, spawnRate);
}
void FixedUpdate(){
// z = player.position.z;
}
public void makeFuel(){
z = player.position.z;
Instantiate (fuel, new Vector3 (Random.Range (56f, 156f), 17.04f, z + 600f), Quaternion.identity);
}
}
Comment