0 Favourites

# How to Overlapped Objects Stick to platform and can move?

• 3 posts
• hi, im trying to make a game where the player can go on platform 2d orthographic, but the platform can be anything and sometimes they rotate.

this formula does not work:

``````//from game object name "obj"
``````

While Obj overlap platform

obj.dist_x = (obj.X - platform.X)

obj.dist_y = (obj.Y - platform.Y)

//below is this formula -> radius = sqrt ( (dist_x)^2 + (dist_y)^2 ) to find distance of points between obj and platform vectors

obj.radiusToPlatform = sqrt( (obj.dist_x * obj.dist_x) + (obj.dist_y * obj.dist_y) )

//below I find in research that atan2(dist_y, dist_x) == angle(0, 0, dist_x, dist_y) in construcyt 2 game engine... so i use it this way, but i mean this: "atan2(dist_y, dist_x) + platform.angle"

obj.angleToPlatform = angle(0, 0, obj.dist_x, obj._dist_y) + platform.angle

//now i set position on top of platform and make sure to factor rotation and angle of it

obj.X = platform.X + obj.radiusToPlatform * cos(obj.angleToPlatform)

obj.Y = platform.Y + obj.radiusToPlatform * sin(obj.angleToPlatform)

[/code:9eqjr807]

anyway this does not work in construct 2 game engine, why???

other game engines this is standard and works fine.

pls, moving at angle does not works well. it is bad.

to explain I need object to not slide around but move with rotation like on a train. or stage platform orthographic view. but still stay in local coordinates the same....... pin movement does not allow offset x and y or added movement, this is not good.