#test if a player is close
1 messages · Page 1 of 1 (latest)
Also helps to show the failed code
Uhhh you can do it with commands using execute as @a run execute as @s at @s run execute if @e[type=<what you're searching for>,r=<radius] run <your command>
It's highly possible that I overcomplicated this but I like making sure that everything works right the first time
....unless this doesn't work in which case I'm a clown
"minecraft:entity_sensor": {
"sensor_range": 2.5, //this is for the radius in blocks it will detect other entities in
"relative_range": false, //if true, the sensor range is additive on top of the entity's hitbox size
"require_all": true, //if true, all nearby entities must pass the filter conditions for the event to send
"minimum_count": 1, //minimum amount of entities required for the event to fire. by default, it's 1
"maximum_count": 4, //maximum amount of entities required for the event to fire. by default it's -1, which means infinity
"event_filters": { //you can put any filter you want here, the one that's being used in this example just detects players
"test": "is_family",
"subject": "other",
"value": "player"
},
"event": "event:on_player_detected" //the event that fires when all the conditions in event_filters are met
}
can i add negative values to this?
so it can detect if the player isnt in range?
I assume this is comming from the entity's point of view... here is an animation controller I made as a test for proximityjson { "format_version": "1.10.0", "animation_controllers": { "controller.animation.isAlone_query": { "initial_state": "isAlone", "states": { "isAlone": { "transitions": [ { "isNotAlone": "v.x = 0.0; for_each(t.player, q.get_nearby_entities_except_self(5, 'minecraft:player'), { v.x = v.x + 1; }); return v.x > 0.0;" } ], "on_exit": ["/say Hi Friend!!"] }, "isNotAlone": { "transitions": [ { "isAlone": "v.x = 0.0; for_each(t.player, q.get_nearby_entities_except_self(5, 'minecraft:player'), { v.x = v.x + 1; }); return v.x == 0.0;" } ], "on_exit": ["/say Where did everyone go?"] } } } } }
that experimental ?
I do not know....
ye it is