Transparency, pixels and colliders

boleyngooboleyngoo Member Posts: 10
edited November -1 in Working with GS (Mac)
Hi
I've looked through some old posts and found a partial answer to my query.
Is there a way to make the collider behaviour activate only when in contact with the actual image or pixel data - ingnoring the transparent bounding box.

Earlier posts have answered the question for regular symmetrical shapes by using cropping within Photoshop or within GS, you can make your own custom collide rule (if the player's position is contained in a global variable). Just check:
if player.x > self.x-10
if player.x < self.x+10
if player.y > self.y-10
if player.y < self.y+10
And you have essentially just created a 20x20 bounding box.

These solutions work for regular shapes but I don't think they work for irregular shapes.

Thanks

Comments

  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Using magnitude for this is a lot more of an efficient way of doing it. You would still need to track the players x and y values, but magnitude is the way to go.

    Ace
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Create a self integer attribute on the collision actor called 'Border' and set to 20 (adjust this to taste - this is your border collision area). Now create 2 real game attributes called 'Players X' and 'Players Y'. Constrain the Players X and Y attributes to the hero's X and Y positions.

    Now on the collision actor, add a rule that says when attribute self.Border is greater than magnitude(game.players x-self.position.x,game.players y-self.position.y) then Collide.

    This is off the top of my head as I'm on my phone, but that's the gist.

    Ace
  • boleyngooboleyngoo Member Posts: 10
    Thanks for your response - I'm not sure that I fully understand but will try to follow this when I have some time.
    Thanks again
    Cheers
Sign In or Register to comment.