I have enemy movement logic that triggers under a certain condition (if item is not held by the enemy, their movement logic fires). It only works on one enemy for some reason, so only that enemy starts moving when their item is taken. I used print string to make sure that the condition to trigger movement is being met and it is, the movement just isn’t firing even though the event to start it is in event tick for the enemy bp?
I am new to Unreal but I’ve been trying to sort this for 3 days now, any help would be appreciated. I programmed the enemies simply into the third person template bp, and they are all spawned in from the same bp & controlled w/ aicontrollers.
Correct me if my understanding is wrong here, but the desired functionality is that ANY enemy that does not hold an item should trigger their movement logic. But for whatever reason, only the first enemy you take the item from will actually work as intended?
If taking the item from any other enemy, will they function as intended? Are only the subsequent other enemies not working when not holding the item?
Thanks for your reply Each enemy has an item in their hands, at which point they are motionless. Once the player picks up the item from the enemy, the enemy begins to pursue them (they only move when the player’s back is turned).
In my code once the item is picked up in the player script, it changes “is item held” to false in the enemy script. This much is working, as I checked using a print string that once it’s taken from any enemy but the first (0), it does mark “is item held” as false, but the movement logic doesn’t trigger.
There are 4 enemies, and only the first is functional essentially, I just can’t tell why
Chances are the reason this isn’t working is because it’s on tick. If tick is restarting your movement code every frame you’re not going to get much of anywhere because you’re not accelerating. It’s not constant, it’s restarting over and over.
That being said, that’s only if you’re using nodes like “SimpleMoveTo” or “AIMoveTo”. If you are doing a LookAt node to turn the enemy then adding movement input on tick that should work. But I’d suggest not using tick for this if possible.
Start an event when the player picks up the object, then start a timer of say, .2, attached to an event “check if being looked at” and if that returns True use “StopMovementImmediately”, if it’s False run your movement code. This will update every .2s instead of every .03s with tick, but it’s hardly noticeable.
Then, if you want the player to be able to give their item back, promote the handle of the timer to a variable, then when the item is given back trigger an event that clears the timer using handle to effectively put it back to default stone state.
Hope that helps! If you have more questions give us more pictures of the insides of those events!