Movable - Unmovable object
LyboTech
Member Posts: 135
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
Best Answer
-
Tosanu Posts: 388
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
Did you constrain their Y motion or Y position?
@Tosanu I constrained the Y motion, as the object is accelerating horizontally (X)
@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
@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 ?
@Tosanu Awesome, now it's working perfectly!
@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.
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.
@Tosanu here is a quick test
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....