I would like to adjust an orbit relative to a solid surface

0 favourites
  • 10 posts
  • Hello everyone,

    I am currently working on a project that includes an object that uses the orbit behavior. My problem, though, is that the object's orbit sometimes will hit the ground. I would like the orbit to adjust itself relative to the ground so that it never goes through the ground.

    Here's a visual representation of what I'm looking for. The orbit is shown in black, ground is shown in red. On collision with the ground, orbit doesn't go through the ground but goes along the green line instead.

    Thank you very much in advance.

  • Probably easier to do it with Raycasting. Here's an example:

    1drv.ms/u/s!AkmrWgxeuxlKhJkPLpVsObFGDvhd6Q

    You could also do it without any behaviours if you new where the interfering object was going to be all the time. Raycast just makes it more flexible.

  • Thank you for your answer Calminthenight. The proposed example is extremely close to what I'm looking for, however it seems very hard coded towards one particular situation. I somehow haven't been able to change the example to be relative to a dynamic center point of rotation. More especially, I haven't been able to switch the last line of the example to work relative to a dynamic rotation point.

    Here's how close I've been, and as you can see, when hitting the ground things are definitely not behaving properly.

    1drv.ms/u/s!Av6DKHz8GbeYkQoh1RVjS9nTc0CV

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also, no, nothing will be at the same place at any time. Neither will be the interfering object, nor the orbiting object or the object in which another will be orbiting around. I need a very dynamic behavior. I am willing to drop the orbit behavior even though I deeply rely on it right now, but if I could use it still, that'd be great.

  • Actually, it's super easy to do with Orbit behavior, all you need is one event.

    On every tick : Sprite set Y to min(Self.Y, Ground.BBoxTop-Self.Height/2)

  • Actually, it's super easy to do with Orbit behavior, all you need is one event.

    On every tick : Sprite set Y to min(Self.Y, Ground.BBoxTop-Self.Height/2)

    Are you sure of this? Can I send you my project so you can verify your statement...?

    I'm not exactly sure about this, since during an orbit behavior, the sprite's X and Y position are overwritten by the orbit behavior.

  • I am sure of this:

    dropbox.com/s/8oegppjba2mhjgd/OrbitClamped.c3p

    If it doesn't work in your project, you can do what I suggested in your other thread - make the object with Orbit behavior invisible. And set position of another visible sprite to it.

  • Wow, this is getting very close to what I'm looking for. However, the object in question is a tileset. If I do:

    Set Y to min(self.Y, mytileset.BBoxTop-self.height/2)

    the player is teleported out of bounds because the tileset takes the entire map. But... this is so close from what I'm looking for.

    I might have an idea. I can store the Y value when the player collides with the floor, and then do the min of self.y and that specific value...

  • To continue with the raycasting example see updated link to project file:

    1drv.ms/u/s!AkmrWgxeuxlKhJkPLpVsObFGDvhd6Q

    It has moving components and you can update the centre of rotation by clicking anywhere.

  • Thanks a lot for the replies everyone. It turned out that Dop's example was what I was looking for. Interestingly enough, the Y value is override if I used the "pin" (and thus would never work correctly), but it was okay if I used "set target", and used the X and Y values of the desired object. I'm not sure this is a desired behavior by the devs.

Jump to:
Order by:
Duplicate Topics
Posts
Views
Last Post
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)