I have a character who plays his walk animation when he walks, but what if he is behind a wall? He would look sort of goofy walking when hes in place. Is there a way I can have a property ("Moving") be toggled to 1 when hes changing his position (not rotation) in 3d space? Any helps is appreciated; I would like to have this in logic bricks if it is simple. Thanks!
You already answered your question by your own:
Behavior: When moving play walk animation
This implies: When not walking -> do not play walk animation.
As you do not explicitly told the character to stop (e.g. by command) you need to detect any events that stop it from moving.
There are many options to detect such events:
- no movement requests from user
- getting other requests from user (e.g. jump, run, stand, crouch)
- hitting a wall
- floating (e.g. when falling, jumping)
- speed below a limit
I guess you want to know the last option. This is not possible with logic bricks. You need Python to activate actuators when the object does not move anymore:
import bge controller = bge.logic.getCurrentController() owner = controller.owner limit = owner.get("limit", 0.001) lastPosition = owner.get("_lastPosition") position = owner.worldPosition.copy() owner["_lastPosition"] = position if lastPosition is not None: travelledDistance = (lastPosition-position).length if travelledDistance <= limit: for actuator in controller.actuators: controller.activate(actuator)
This needs to be activated all the time (enable True Level Triggering).
- this is inefficient and should be used at a very limited number of occurrences
- this does not differentiate between other situations when the character is not moving (e.g. sitting, sleeping)
- you can tweak the limit by setting a float property limit