How to do smaller collision volume vs image size?

ThreepwoodThreepwood Member Posts: 30
edited November -1 in Working with GS (Mac)
What if you have a character that's wide when they shoot (say 200 pixels), but you still want their collision volume to be something like 64 wide? If you set it to 64 wide in the actor then the image clips when you place it in the scene and there are rendering issues. I have to use fixed vs tile or stretch.

Is it possible to have a separate collision volume or dimensions for an actor that's not tied to the dimensions of its art?

Comments

  • StusAppsStusApps Member, PRO Posts: 1,352
    sure,

    create an invisible actor with alpha set as 0 at size 64 wide, then constrain it's x and y position to your original actor. Then set the colision rules with the invisible actor and not the main one.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    there is one other option that I find myself using a lot. The circle collision shape is always a perfect circle centered in the actor - it is never an oval. So if you make an actor that is 64 tall and 128 wide the collision zone is a perfectly centered circle with a diameter of 64 pixels. This means that if you have an actor that is holding a gun pointed out in front of him, the gun will not collide if it is more than 32 pixels (the radius) from the center of the image. So in one of the games I am working on I have these guys standing in a circle, but what is really going on is that the width of the image file is the diameter of this circle but the height is much greater. So as the guys float around you have to avoid the circles they are standing in but if the body that sticks out above the circle collides with you GS ignores it. Anyways just try making a perfect circle in photoshop but then set the canvas to be a rectangle and not square. then in GS set the collision shape to circle and you will see that it will treat the actor as if it were a perfect circle even though the png file is not a perfect square.
  • synthesissynthesis Member Posts: 1,693
    For a button effect, if the tap zone is a rectangle...I often use a rule to define it...like this:

    Rule: When Touch is Inside
    .....Rule: When Touch is Pressed
    ..... .....Rule: When Touch is <= [x max] and >= [x min] and <= [y max] and >= [y min]
    ..... ..... ..... [ do something ]

    You can add more than 1 rectangle zone on an actor if you wish by adding additional rules.

    BTW:
    This only works for tap zones (like a button) and not for collisions. For collisions...The other solutions work best.
  • ThreepwoodThreepwood Member Posts: 30
    Thanks tshirt,

    The distance/magnitude would work well but it's a shame to have to do such a thing. Most engines have the concept of the base art, then a bounding box that can be any arbitrary size, to collide with that actor. Would be two more simple properties GameSalad should add to actor attributes.

    If you're making a Zombieville style game you may well want the collision with your character to be 128x64 but the art may stick out further past 64 wide and you don't want an enemy colliding until he hits the "meat" and not just the tip of a long rifle or whatever.
  • ThreepwoodThreepwood Member Posts: 30
    StusApps,

    an invisible actor of the size you want, constrained would work as well. Guess it's just one more actor. At least in that scenario you can still use the collide logic built into GS and not have to have your own.
Sign In or Register to comment.