Spawn Actor inside Viewport Size

hello im currently making a 2D mobile game ive set the player to get kill when player get out of view of the camera but now my problem is that i want to spawn coin inside the viewport size at random point inside of it

ive made this but it dont seem to work properly any help will be very helpfull

I think you probably need

i looked the video and this is not im actually searching i really need to spawn coin inside the Viewport size (inside the camera view) at random point, i need this because mobile platform have different size of the screen and if i dont do that the player could not see the coin if i put target point it will be outside the player view so that why i need to have the current value of the viewport size and spawn coin inside of it at random point but idk how to do that Smh

Yes… just do 2 random floats between 0 and your viewport size, and project that into world space, which is what the vid is about…

it work but it only spawn in positive direction how to make it work in both positive and negative direction of the viewport size?

thank for the reply

Surely you want to choose a random point on the viewport, and then translate that to world space?

Hang on, that’s not right…

actually how i made my blueprint is when player collect the coin it destroy the coin then it spawn the coin at an random point on the viewport size since the camera is static the coin spawn but it need to spawn at random point on the viewport but for now it only does it in positive direction but also something it dont spawn correctly

Ok, I have it, no obvious… gimme a minute…

Right. If the camera is facing down the Y axis, this will pepper coins 500 units from the camera, all over the viewport:

This is me spawning coins by just repeatedly pressing the mouse button:

345466-ezgifcom-gif-maker.gif

THX DUDE ! you resolved my problem !!

Ps: with this system do you know a way to spawn obstacle but it will never merge with each other

ex: i spawn 2 coin to never touch each other

Ah, then, you have to keep an array of where you have already spawned coins, and check against that.