Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
How to scale physics collision shape with renderer?
  • This started as a question I was about to post, but then I figured it out.

    Example I have a ground spatial that is 100 by 100 and I want to scale it to the screens width depending on the different screen sizes.

    Take Game.Screen.Width/(size of spatial I want scaled) = scaling sizes

    Now if you create an object that on load renders that object and applies the scale to the spatial that will create your object and scale the collision spatial correctly.
  • 3 Comments sorted by
  • @Carlton are you using the "collisionShapeScale" point object property on the collision spatial?
  • I wasn't, I implemented this last night and it works perfectly. This is extremely useful.

    Thank you
  • @Carlton I have been scaling down my game to test on a smaller device, in GBs i toggled the show spatials so I could see what they look like on the device(on a character  which is 130x150 for example) and they do seem off.
    So are you saying when we are setting up a condition to check for a smaller screen we trigger a:
    change property
    @Spatial.collisionShapeScale = Type expression  Game.Screen.Width/size of spatial

    if the size of character is a width and height(130X150) what do you put for size of spatial in the expression?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion