Scale an object to another object collision size every frame

0 favourites
  • 3 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hi all, Hope everyone had a great holiday season

    I have a sprite object that has a collision box that changes depending on it's frame of animation. (It appears to rotate 360° at a 3D angle even though the sprite stays static, therefore it's collision box changes dimensions every frame)

    There is a base object that this animated sprite is pinned to. It's a rectangular physics object. That's our main object, and this car sprite simply changes animation frames to match the angle that this base physics object is moving in (for example if the physics object is moving at 90° then the animation frame of this sprite is set to 18 etc)

    I thought I was being real clever with this but perhaps not. I guess this is what you get when you try to fake 3D? Obviously the base physics objects rectangle would have to have slightly different dimensions depending on the angle we're moving in order to match it's accompanying animations.

    What I need to do is change the size of the base physics object so that it always matches the size of the animated sprite's collision zone. Would anyone have any idea how I could do this, that's if it's possible at all?

    Apologies if this isn't very clear. I am aware that this is a bit of an unconventional apporach to faux 3D.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't read collision polygon size, but you can get image points position. So the solution would be to define 2 image points on each frame and then adjust your physics object accordingly.

    Use sprite.imagepointX(mage point number or name here) and sprite.imagepointY() expressions.

  • Ah yeah. I seem to remember you and mekonbekon had some great examples of something along those lines here...

    I reckon that's a good way to go, but maybe a bit outside my skillset (I only have so much hair left to pull out). I think I may have a less sophisticated solution.

    I can go through every event that progresses the animation, and then set the size of the base object so it changes depending on the angle. Like dis...

    Its not elegant or quick but it should do the business.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)