Is there a way to check if the player is facing towards an event for, say, a conditional branch?
How to check if player is facing a certain event
● ARCHIVED · READ-ONLY
-
-
There is a conditional branch check for if the player is facing a certain direction. Its on Tab 3 of the conditional branch box. Character-Is facing (direction)
-
There is a conditional branch check for if the player is facing a certain direction. Its on Tab 3 of the conditional branch box. Character-Is facing (direction)
I know about that, but for example, if you face down, but not face the event, it will still activate. -
That doesn't help unless you know what direction the event is in relation to the player. Because one or both could move.
If the event is only one tile away vertically or horizontally, it would be easy - you'd just use existing methods to get the tile in front of the player and see if that's where the event is. But if they are more than one tile apart, or not in a straight line vertically or horizontally, it becomes more difficult - then you have to consider distance as well as field of vision. It wouldn't be a short formula and might be better off written as a script addition that can be called from the conditional branch Script box. -
Oh so you just want to know if a player is in-line with another event? You can set up region IDs and track the player's location just set them around your event area. This video is for pitfalls but you learn the basics of tracking a player's location in it.
http://finalbossblues.com/video-pit-region-ids/
Granted you didn't say whether your event was moving or not, etc.. so im assuming it is stationary. -
I asked if the event would be right next to the player. The OP didn't state that it would be.
-
What I'm trying to make is an on-screen creature that acts differently when you're looking at it, I guess I should have been more specific. I don't believe region IDs would work for this because the event would be moving.
-
Try something like this in a script box - I've used switch 15 and event 7 - change those numbers to reflect the actual values:
Code:p = $game_player; e = $game_map.events[7] $game_switches[15] = false dx = (p.x - e.x).abs dy = (p.y - e.y).abs case p.direction when 2; $game_switches[15] = true if p.y < e.y && dy >= dx when 4; $game_switches[15] = true if p.x > e.x && dx >= dy when 6; $game_switches[15] = true if p.x < e.x && dx >= dy when 8; $game_switches[15] = true if p.y > e.y && dy >= dx end
Put that immediately before your conditional branch, and have your conditional branch check the switch. If the switch is on, the player is 'facing' the event.
This allows a 90 degree field of vision - if the player is facing up, the event will be 'seen' if it is higher than the player and within 45 degrees to the right or the left.
You might want to add a Wait 4 Frames before the script command, as the event is not going to move to a new tile 60 times per second, so it'll reduce the possibility of lag. -
Try something like this in a script box - I've used switch 15 and event 7 - change those numbers to reflect the actual values:
Code:p = $game_player; e = $game_map.events[7] $game_switches[15] = false dx = (p.x - e.x).abs dy = (p.y - e.y).abs case p.direction when 2; $game_switches[15] = true if p.y < e.y && dy >= dx when 4; $game_switches[15] = true if p.x > e.x && dx >= dy when 6; $game_switches[15] = true if p.x < e.x && dx >= dy when 8; $game_switches[15] = true if p.y > e.y && dy >= dx end
Put that immediately before your conditional branch, and have your conditional branch check the switch. If the switch is on, the player is 'facing' the event.
This allows a 90 degree field of vision - if the player is facing up, the event will be 'seen' if it is higher than the player and within 45 degrees to the right or the left.
Is there a character limit for the script box? It's not letting me paste that into it. -
There is a character limit (or rather a line limit) but I typed that into the Script box in my game, so it works.
Those longer lines - does it break them over two lines instead of just one? If it does, you don't have the latest version of Ace. In that case, just redownload and reinstall to the same location. It ought to work then.