Movable - Unmovable object

Might be an odd question or really easy to solve but I'm having a hard time solving this.
My platformer game has platform-type objects moving towards you and I want my character
to be able to run on top of these without interfering with the platform's rotation or motion.

I tried constraining the objects linear Y value to 0 but it is still interfering a bit.

If that makes sense ?
Thanks for any help :smile:

Best Answer

  • TosanuTosanu Posts: 388
    Accepted Answer

    If the platform doesnt have to move in Y at any point, you can instead first get Core Y, and then constrain Position Y to Core y.

Answers

  • TosanuTosanu Member, PRO Posts: 388

    Did you constrain their Y motion or Y position?

  • LyboTechLyboTech Member Posts: 135

    @Tosanu‌ I constrained the Y motion, as the object is accelerating horizontally (X)

  • ashtmjashtmj Member, PRO Posts: 405

    @LyboTech Add a real attribute to your ledge actor called "core Y"

    then add these rules

    change attribute core Y to self.position.Y

    then a constrain attribute

    constrain self.motion.linear velocity.Y to 20*(self.Core Y-self.Position.Y)

    then just make sure your player actor and ledge actor have almost the same density.

    hope that helps!
    -Ash

  • LyboTechLyboTech Member Posts: 135

    @ashtmj‌ Thanks for the suggestion, it doesn't differ much at all really, I still get the trampoline type-effect when landing on the ledge. Any special things I have to do with density ?

  • LyboTechLyboTech Member Posts: 135

    @Tosanu‌ Awesome, now it's working perfectly!

  • ashtmjashtmj Member, PRO Posts: 405

    @LyboTech

    in this part of the code: 20*(self.Core Y-self.Position.Y)

    change the amount from 20* to something like 0.9* or 5*
    the greater that number the greater the push the ledge will have to get back to it's core Y.

    so if you lower that and make the ledges density less then that of the player it will stay in one spot. if you make it REALLY low the ledge will sink down, and if it's higher and the ledge will push/spring the player up.

    you also need to set both the player and the ledges bounciness to 0 or 0.1
    (it needs to be low)

    @‌Tosanu The reason I always do constrain self.motion.linear velocity.Y rather then just constrain.self.position.Y is because it allows the player actor to collide with the ledge better. in my experience constrain.self.position.Y often makes the player fall though the ledge if you stay on it too long. using motion fixes this issue.

  • TosanuTosanu Member, PRO Posts: 388

    Really? I;ve never had them fall through. Are you sure its the constrain position that does it?

    I find the problem with constraining motion is that the actor tends to strain against it, and it causes jitters with enough force.

  • ashtmjashtmj Member, PRO Posts: 405

    @Tosanu here is a quick test

  • TosanuTosanu Member, PRO Posts: 388

    I've seen that effect, but I know ive beaten it while still using constrain positions. I'm honestly can't remember what ive done differently now, though....

Sign In or Register to comment.