I have a dog follow behind me but i was wondering if there was a way to get it to follow beside me or to run ahead of me a little bit?
I presume you have a target location within the AI that uses an adjusted address, likely behind player as the dogs target. You can instead use an array of targets that include one or two out in front of player and some at players side.
You could calculate those targets from the players location, forward and right vectors or you could decorate player with scene component children and keep an array of their references that lets your dog AI update the address as player moves.
I would place such targets so they avoid collision with player as much as possible since the dog will have to at times move faster or slower than player to make use of the targets. In other words, I might place the scene components at 45 degree angles in front of the player, so dog can go past player to get to them. I would probably pick 6 positions to place the targets, front left, front right, left, right, behind left, and behind right.
Once the dog reaches the target selected, then pick a new target from your array of scene component references.
I tried the component thing, like I put a ball or whatever that the dog could use but it wouldn’t let me cast to the component or reference it or anything like that, I wish there was a tutorial as this would be so great to have in my game
this sort of works, i put the dog in the same actor blueprint with my soldier but when i turn the camera the dog turns with it and it doesn’t exactly look right lol
I didn’t notice your reply until the summary email arrived that the forum sends out.
I don’t do blueprint-only programs, so my normal method of creating a communication that allows references to go between player and followers, is done at the C++ level. I’m not sure how it’s handled in a blueprint only context, so my comments may not be best practice.
You could register the components with GameMode, GameInstance or LevelScript (any "well-known"easily reachable and cast-able class). Then the follower could obtain them from that class. GameInstance might be best if the concept is going to persist across levels.
Using that as an example, a derived GameInstance class would have public (eye-opened) variable of an array of components populated by the the player character. In the follower, once the array shows as IsValid, it can be used.
The retrieval of this in both player character and follower would be done using a Get GameInstance followed by a cast to your derived class. Start-up timing always has to be taken into account since the only synchronization is whether the array has become populated and has become valid to use.
Again, this may be considered a travesty to experts in blueprints, but it will work. Sorry I didn’t see your responses, I know how frustrating that can be to receive no replies.
Edit: I didn’t think to ask why you weren’t able to just Get the player controller (0) cast it to your derived player controller, then get a component array directly out of it’s character pawn (cast to your derived character class). In that case, your player pawn would have to have created that public array that gives the component references, but you should be able to pick it up from there.
Two ways.
The right way would be to use EQS to find a dot notation to the side of the player and move the AI to there.
Easy way is to put an arrow component next to the player, where the dog should be, and move the AI to there.
Both ways have their pros and cons.