marvster Posted June 18, 2014 Share Posted June 18, 2014 Hello together, I'm currently trying to figure out how a player (avatar) on a topdown map may interact with other objects on screen by pressing the action button. And I'm totally locked in a stalemate. Here is my set up:A player sprite with a body (arcade) which is movable with a facing direction (up, down, left, right) a isLocked flag (if he interacts, prevent new interaction) A group of NPC, each sprite has a body with an interactionType (dialogue, shop, none) an optional dialogueList [dialogues [{speaker, spokenText}, ..], ..] to choose from. an optional shoppingList [{item, price, quantity},...] A group of (non-physical) Objects with an interactionType (pickup, door, event) an optional itemId and itemType (item | weapon | questItem) an optional eventKey (to call the event) an optional locationKey (to set the map for changing) An input key which, when pressed, will check a nearby object, which means an object standing on, or an npc standing next and evaluate the object (interactionType) and make a decision how to work with it (open a dialogue with passing a random set of dialogueLinesWhile evaluating the object actually comes easy, finding and passing by an object brings the horror.If tried collides, overlaps and touching, all falls short while it is needed actually walk into an object to trigger a function - if I just stand next a npc and stare at him, none of the events is true. I've read about blocked, but it will just tell me if true or false, but nothing about what is blocking me. And for none-physical objects all four options fall short, as they must not have a body (so the player can stand of it).Can anyone help me to set my mind back to the right direction? Link to comment Share on other sites More sharing options...
ragnarok Posted June 18, 2014 Share Posted June 18, 2014 We discussed some possibilities here:http://www.html5gamedevs.com/topic/7004-check-if-a-body-is-next-to-another-body-but-not-overlapping/ Link to comment Share on other sites More sharing options...
marvster Posted June 20, 2014 Author Share Posted June 20, 2014 Thanks a lot, that was giving me the clue. I've set a key-less child sprite to the player in the same size and set the anchor depending on the direction the player look (0.5 +/- 0.25, 0.5 +/- 0.25), to let it leap a bit of.With this "sensor-field" I can work with overlap to pass the object for evaluation. Works like a charm. Link to comment Share on other sites More sharing options...
Recommended Posts