Page 1 of 1
Detects side collision
Posted: Sun 7 Jan 2018, 03:38
Hello guys, as you can view in the image below, i need to detects if an sprite has an object at left (or right) and if this object has an Object's variable value equal an specifyed. i know about gdevelop didnt has an "left collision" and "right collision" but we can simulate this creating an linked extra-object?
sorry, but my english is stupid yet.
so if it not right, sorry!!!
Posted: Sun 7 Jan 2018, 10:28
You can create an object that you will place at 0 degrees or 180 so I believe left and right the object must be diferent and created a collision event that will tell you if it is right or reverse - view the object is hide - when the collision you created the event wish ... (position demender)
Re: Detects side collision
Posted: Sun 7 Jan 2018, 17:59
I don't think I completely understand what you want to do, but checking for a collision on the side of an object can be done by comparing the X positions of the colliding objects.
If player.X() < otherobject.X() then the colliding object is on the right of the player; if player.X() > otherobject.X() then it is on the left. You can do these checks with the "All objects>Position" conditions.
If you need to check whether the other object is above or below the player object then you do the same, but checking the Y positions where player.Y() < otherobject.Y() would mean the player was higher than the colliding object.
These will only be of use if the player actually touches the objects to the left or right of them. If you want to detect the objects from a distance, you will need to do it another way.