0 Favourites

How to Overlapped Objects Stick to platform and can move?

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • hm.. maybe it a bug with construct 2.. i give up

  • upload a capx file.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
564 105,241
rexrainbow's avatar
rexrainbow
Unread hot topic
0 Favourites
Tutorial: Platform School
267 93,738
Megabeard's avatar
Megabeard
Unread hot topic
121 11,760
Artpunk's avatar
Artpunk