I have a Turret aiming at a (Mesh,Object) in the world. and in order to finish my node set up i need to get the location of my mesh so that the turret can target it.
I know to get the location for a Player, The nodes are ( Get Player Pawn ) And ( Get Actor Location ) but i can’t seem to find one for a Static Mesh?
So i Guess my Question is… Is There a node for Mesh Location? or is that not possible?
Any input or know how on this matter would be greatly Appreciated.
The turret will also be an actor. (If it’s just a mesh dropped into the scene, it will be converted to a StaticMeshActor if I recall correctly). In any case, you need a reference to the turret and you should be able to use the GetActorLocation() function exactly as you did with the Player (the Player is also an actor).
If you can post some more details about exactly how the turret is set up I can give you some more detailed help.
Here are some screenshots…
The Sphere represents the Turret and the Box is the Mesh i need the Turret to target. And i have everything set up i just can’t figure out to get the location for the Mesh. (The mesh isn’t a Player it’s just a Mesh in the world) Do i need to make the mesh into a actor?
Thanks Man… i didn’t even think of that, That and i’m Terrible with BluePrint Lol…
See if you can create a reference to the box mesh in your Blueprint, i.e. select the Mesh in the 3d view, then go into your Blueprint, right-click and “Create a Reference” (see documentation for more details).
Once you have this reference, drag it onto the Blueprint and you should be able to call GetActorLocation() on it.
So I assume that solved the issue? Would you mind accepting the answer so it can be marked as resolved please? (I need my AnswerHub karma lol!)
Ok… I tried it and it worked! but it only let’s me Reference it in the Level BluePrint. it won’t let me move it to my Turret Blueprint? i tried (Copy and Paste) but it says (Node Unknown)?
And i’am gunna put mark solved but if you can still give me some insight on this last piece…
Ah yes. The Turret Blueprint won’t know about anything in the level in that way.
You will probably have to do a bit more detailed design work on your own, but to give you an idea of what you’ll need to do: in your Turret BP, you can use an [iterator][1] to find some Actors to attack. Now, if you think about it, this gives you a lot of freedom, but also makes it a bit more difficult. You can iterate and find all StaticMeshActors, but the results would probably be a bit silly, as you probably don’t want the turret to attack walls and floors and so forth. So what you’re looking for is to create some logic inside the Turret’s Blueprint that determines what it should attack. For example, you could iterate through all actors, check whether any of them are of type “Character” and if they are closer than some given distance from the turret, it should attack them. To check whether an actor is of type “Character” you can use [Typecasting][2].
E.g.
is a screenshot of a Turret Blueprint I’ve created that posts a message when my game’s PlayerCharacter is within a certain distance from it.