collide with absolute edge of actor

emperorgregemperorgreg Member Posts: 2
edited February 2014 in Working with GS (Mac)
Hi guys, I've searched for an answer on this site but only found one thread which didn't really help my situation.

I have been working on a little feature in which a character is able to hit the top of an actor but if it hits the side or bottom, a different action is triggered. I have followed what seemed like a very good tutorial online (jamie-cross.net) to achieve this but there is a problem with the precision of the collision detection.

Here is a quick summary of my function and the problem it has been experiencing:

- I set up two global real attributes, charBottom and enemyTop
- Constrained char bottom to player bottom; self.position.y - (self.size.height /2) +10
- Constrained enemyTop to enemy top; self.position.y + (self.size.height /2)

set up rules on character:
- if character collides with enemy then:
- if charBottom >= enemyTop
- self.motion.linearVelocity.y to 250

- if character collides with enemy then:
- if charBottom < enemyTop
- pause game

I set it to pause game since originally it was set to bounce, but I noticed it was bouncing where the linearVelocity action should be triggering (an inconsistent bounce height gave me a clue to this)

I had to increase the amount of pixel lines on the first constrained attribute from 5 to 10, this lessened the issue but it still persists. Increasing it further would help more but the 10 pixels fudge is already far less accurate than I would like to have.

Has anyone else run into this problem and found a work around which enables you to keep a high precision?

EDIT: Forgot to mention that when I hit the top of an enemy, about 9 times out of 10 all is fine but sometimes (seemingly randomly) the second function is hit and the game pauses.

Best Answer

Answers

  • AppTacoAppTaco Member Posts: 125
    Have you tried throwing a "Bounce when collide with actor of type 'enemy'" behavior in the character actor? This might fix your inconsistency when the actor hits the top of the enemy.
  • emperorgregemperorgreg Member Posts: 2
    Hi PES, thanks for the reply. I did originally have the bounce function in place of the linearVelocity but this resulted in varying degrees of bounce distance/height depending on what speed the character falls or from how high they fall. This was not what I was looking for.

    If there is a way of specifying a constant bounce distance then this should indeed solve my problem but being a noob to gamesalad I am unaware of any such method.
  • emperorgregemperorgreg Member Posts: 2
    PureEpicStudios my sincere apologies for my late reply. Your solution looks to be exactly what I'm looking for. I did not realise that the bounce effect would be overridden. Thank you so much this has been a big sticking point for my little project.
Sign In or Register to comment.