Y offset issues with interpolate

Apologies for the wall of text, hopefully this makes sense. Hopefully.

I'm currently running into some issues trying to dynamically shift an actor's Y position.

I have a game where actor A and actor B move horizontally to the hero character. When actor A collides with the hero a point is scored and actor A is destroyed. The hero has to jump of actor B. I wanted to have an interp effect on the hero to make it constantly grow and shrink a little bit, whilst sitting on a platform, giving the illusion of getting taller and shorter. Unfortunately this interp effect causes the collision rules to go wrong - they don't fire when the hero's size is being interpolated.

Easy enough I thought, I'll have another (invisible) actor behind the hero, without all of the interp effects. The collision rules will trigger with this invisible actor, and I'll constrain the Y to the hero actor, so that when one jumps the other does.

Unfortunately, I now have a hero actor with a height that grows and shrinks repeatedly, with a fixed Y position, not sitting on top of a platform. Which means that instead of sitting flat on a platform and getting taller, it grows from a fixed point in the middle.

What I want to happen is create an offset to the Y position, to give the illusion that it's getting taller, not growing from the middle.

I've tried what seems to make sense in my head: constrain self.position.y to game.hero_y+(self.size.height/2) but for some reason this prevents the interp rules from kicking in at all.

So back to the drawing board - anyone have any suggestions of where to look?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2014

    Hi @imjustmike here's a different approach you might want to try:

    Interpolate the height to what you want, and over the same time, Interpolate to the actual final y position.

    Here's a sample of what i mean:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • imjustmikeimjustmike Member Posts: 450

    @gyroscope‌ that's a great shout. Annoyingly it won't work quite perfectly due to the timings of interps not quite lining up but it smooths it out a lot! Thanks :)

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @imjustmike‌ -- your first way should work. Just use
    (self.size.height/2) + (whatever Y position should be the bottom)

    I think its the "game.hero_y" that is throwing things off. Are you sure you want that for the bottom Y position?

  • imjustmikeimjustmike Member Posts: 450

    @RThurman‌ Well I actually have an offset in there too to find the bottom Y. My issue is that using this rule actually prevents the interp rules from kicking in. Which is strange.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Take a look at the attached file. Is it what you are looking for?

  • imjustmikeimjustmike Member Posts: 450

    @RThurman‌ that's exactly right. Bizarrely it's almost exactly what I was using, but in a different order. Didn't think that would make a difference, but apparently it does. THANK YOU!

Sign In or Register to comment.