I’m creating a top-view game like air hockey. I’d like to create an enemy that follows me with the same behavior, but I can’t think of a good way to do it. someone please help me
The poster is Japanese and is not fluent in English. Sorry if my English is wrong
Here’s a tutorial
In your case, since you have obstacles in your scene, you would need to use the AI Move To node. But if you didn’t, I just wanned to add there’s another way for enemies which don’t get affected by any obstacles. You can also simply use the “Add Movement Input” node and plug your enemy character’s forward vector into it’s direction pin to always make it move forward, and to make it always face the player, you can use the “Find Look At Rotation” node, plug in both the enemy and the player’s locations in that node’s pins, and use the result to rotate the enemy character by plugging it into the rotation pin of the “Set World Rotation” node. All these should be executed after the Event Tick. Though don’t forget to put a condition before the Add Movement Input node to make it stop moving if certain conditions are met, like when it gets in a set radius on the player.
Hope this helps!
I am personally allergic to NavMesh so I don’t fool with it. This is one of those questions like to be or not to be…er…“to move or not to move”. So you need a method of propulsion for the NPC. There seems to be a few methods and there are caveats to them all. For example some need a character bp (hence the capsule component), some need a pawn.
One of the easiest ways to get something to move I have found is the method that uses set actor location in this thread SHIPSCROLLER (Side) - General Movement Theory.
In my Beat Em Up template, I needed a way to propel the camera actor along parallel to the player(s) and smoothly, not too fast or slow. not herky jerky. What seemed to work there was “Add actor world offset”. I’m currently experimenting with that to move the NPCs.
I’m finding with game development you really have to break down what exactly you are trying to do and then work out a way to achieve that. You say it is a top down hockey esque game. SO, you want those “players” or “opponents” to obviously try to score and get into a “goal”.
So the pandoras box that you have opened here is “enemy movement behavior”. What do they do? It would be like playing Mortal Kombat 2 against a cpu controlled Liu Kang. As soon as the fight begins, he may come at me with a bicycle kick. That is a possibility…and perhaps it is a 1-10 chance…1-20 chance…who knows.
I am not sure what to tell you for enemy movement behavior here. EMB is such a complex thing. I have been working on this BEU template off an on for years and am just now starting to wrap my mind around EMB. If there is no projectile or “puck” in this game and rather the character scores by just being in a goal zone or just beyond it. Then perhaps have the npc go straight for that goal at begin play, and if the third person character can block them for a certain amount of time then have them retreat and regroup and try again. I have no idea.