Hello guys This is my first question Im newbie in unreal engine.Im start watch some tutorials and trying make like a “Dark souls” style game. Now everything normal but im stuck in camera lock on thing… Okkey my problem is " My camera lock on working good if i see 1 enemy but if im see 2 or more enemy . . . my camera lock on try to lock every enemy!. I want only choose 1 enemy ( maybe im try distance thing but i dont know how i can make ) here my blueprint
Normally im not a coder or another thing im just making 3d model,animation and yeah im graphic artist but im really want to make somethings with my models ^^
Already thanks for help ^^ and sorry for my ultra bad english
Your problem appears to be with this node transition:
Get All Actors of Class will obtain every character in the level, including the player, and then feed them into the lock on node. You need to narrow it down to just one; ideally one that is onscreen and close to the center of the player’s field of view.
[This question][2] has information on how to determine if an object is on-camera or not. You can experiment with your own criteria as to which one it would pick as the default lock-on target. I would use two points to define a line forward from the camera and figure out what’s closest to that line; this would bias towards the center of the camera’s field of view, allowing players to manually choose what they’re locking on to. You might decide to pick the character that’s closest to the camera instead, or something else altogether.
One thing you definitely should not forget is to avoid locking onto the player’s own character. I suggest using an enum or an integer variable to mark what team the player’s character and the enemies are on, if you don’t already have that available. If a potential lock-on target matches the player’s own team, skip it – you just want opponents.