Question by
sonnynomoney · May 04 at 02:04 PM ·
vector3
How to use Vector 3 Z position as a range?,Trying to do a Vector3 spawn range for position Z
Hello,
I am trying to create spawn range that spans across the x range, same y position, and a z range. I was able to get it to span across the x range, and the same y position but i cant figure out the z range. I was hoping you guys can help? Here is my code:
// Start is called before the first frame update
void Start()
{
InvokeRepeating("spawnPowerUps", gameDelay, spawnInterval);
}
// Update is called once per frame
void Update()
{
}
void spawnPowerUps()
{
int powerUpIndex = Random.Range(0, powerUp.Length);
Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), (spawnPosY), (-spawnPosZ, spawnPosZ));
Instantiate(powerUp[powerUpIndex], spawnPos, powerUp[powerUpIndex].transform.rotation);
}
}
The spawnPozZ will not accept that entry I used.
Comment
Your answer
Follow this Question
Related Questions
Turn a vector3 relative to a look direction 1 Answer
How do I convert world space Vector3s to terrain based coordinates on the [256,256] scale? 1 Answer
How do I specify the origin and end points of the arc1 instantiated line? 0 Answers
What about DelayedVector3Field method? 0 Answers
How to properly make an object follow the edge of another object? 0 Answers