How spawn an actor on the left side of the screen?

How spawn an actor on the left side of the screen?
I thing use “Convert Screen Location to World Space” node
but how exactly?

Use “spawn actor from class” node, choose the appropriate class and hook up the “world location” output from “convert screen location to world space” to a “make transform” node and then hook that up to the “spawn actor from class” node. Make sure scale is set to 1.0 for X,Y and Z. Or any non zero value, just so it can actually be seen.

Also to put in the “screen X” and “screen Y”, get the mouse position with the “get mouse position” node. If it needs something for the target, hook up a “get player controller” node to it.

You may want to alter the Z value (assuming you’re looking down), as it will pretty much just spawn the actor at the camera.

I know how to spawn actor. But how to find left side of the screen in world space? This is need to: enemies that spawn in right side of screen move to actor/location located in left side of screen.
I Used:


but…

Is your game on a 2D template? Or are you using complete 3D?

3D, like “Trine”. But without main character model.

So to make sure I understand, you’re trying to make it so that something spawns or moves towards someplace clicked on the left hand side of the screen and you need to convert the mouse coordinates when on the left hand side of the screen to the appropriate world space coordinates?

I don’t know if this helps, but for my project, a somewhat top down 4x game, I needed to do somewhat similar thing, so I could place structures where I click, but because it’s at an angle, and because the view isn’t orthogonal, I needed to project the mouse and have it locked to the X/Y axis.

Eventually I came up with this.
The Z input is so it’s locked to a specific height on the Z axis, though ultimately, if you ignore the break and make vector at the end, I think it will just get the world space on what ever is under the mouse on the specific channel.

Then for it to only work on the left, just a bit of maths, most of the stuff in the picture you posted would work, all you would need is, to see if the mouse position in screen space is < the result of the division you did. (I think)

Not exactly. Its simple to find mouse coordinates.
I’m not do click.
Enemy just spawn somewhere and move to left side of screen. Without mouse clicking.
10896fc9c2c3459309e3455231c3f172a59f2ee4.jpeg

A few more questions if that’s ok.
Does the mouse location matter at all? (Looking back, not sure where I thought you needed it. Perhaps I should ask questions first then make assumptions lol)
Does the unit spawn location need to be at a single point on the left? Or can it be anywhere as long as it’s on the left hand side? (As in for a 1920x1080 resolution it can spawn anywhere between 0 and 960)

That said, I think I’m starting to understand, sorry for being a tool.
And if I am understanding, perhaps a spawner would be best, you would place it manually in world space and you would just tell it what and when to spawn a unit. Instead of always calculating the location.

Its ok, and thanks. :smiley:
mouse is not used, absolutely.
Enemies spawned on the right. At points scattered on the level.

Is it pretty much a sidescroller platformer with what ever other mechanics you’re adding?
And the enemies spawn in various locations through out the level?

Well, actually, yes. I want to implement the kill of the enemies of the mouse.

In various points of the level. To the right. Outside the monitor screen.

Ah ok, I understand now.

Hmm, well spawners would still probably be your best bet, as it would make it easier to change where and what type of enemy to spawn, but the issue is activating them at a certain point when the camera get close, this is pretty much a world space dilemma.

You could check for the camera distance on a given axis but doing that every tick would be wasteful.

So your best bet is probably to make use of collision detection a box that moves with the camera but extends beyond what you can see. I would have the box in the same blueprint as the camera and with every tick, update the box on the X/Z axis (assuming that Y in this case is depth)

Create a custom object channel just for triggering spawns and name it like “SpawnCameraTrigger” or something (of course you don’t have to), with the default set to ignore, so you don’t have to set everything to ignore it, and don’t forget to set the box that’s connected to the camera object type to the new channel.
Here’s a link in case you don’t know how: Collision | Unreal Engine Documentation

Then in your spawner, create a small collision box, and set it to ignore everything, but also set it to the new channel and add the “On Component Begin Overlap” node, and then add the logic to spawn the enemy from this node.

This way, it will only spawn as soon as the box touches it, and with the new channel, nothing else will trigger it.

You could also destroy or disable the spawner (disable it will simple boolean logic, check if it has already spawned, if not spawn and set the bool to true, if it has, do nothing) after it spawns an enemy, this way you wouldn’t have enemies spawn when ever you back track.

No, it seems that you do not understand.
The question is not how to spawn enemies. I know how to do it.

The question is how to find a point in 3D space, which will seek to enemies. The exact coordinates of where to put it.
But it should be at the edge of the screen.