How to Spawn an object at a random position on the screen

Hello,

I am trying to spawn an object at a random position on the screen. Does anyone have any code as I am not sure how to. Thanks.

The Circled Meteor is what I need to spawn in a random position.

I’ve already seen that video. It doesn’t really help me. Is there not another easier way to spawn at a random location like setting a random integer to be X and another one to be Y and then using the rigidbody transform.position to move to x and y?

e

What about the next X videos??

We know Random.Range() gets you random numbers (Read the docs for critical details, or just experiment)

We know the Vector3 constructor makes you vector positions. This is just vanilla C# constructors.

We know that assigning a Vector3 instance to transform.position moves the GameObject to that position. EVERY Unity game that moves a GameObject uses it.

Get crackin’… get this stuff down COLD… this is the EASY stuff!

I am new to unity and I managed to fix it but then scrapped the game as it didn’t have any potential. I’m still learning. I know a lot more now

1 Like

None of my games have any potential… I make them because it pleases me greatly, and as a side benefit, I get to play them!

A few other people like them too, but I don’t make any money off my games. I just learn from them.

Apple:

https://apps.apple.com/lu/developer/kurt-dekker/id680019078

Android:

https://play.google.com/store/apps/developer?id=Kurt+Dekker&hl=en_US&gl=US

Thank you. I’ve started a new game which I am really enjoying making. I’ll look at those links