Please help with this ASAP :)

rickynikorickyniko Member Posts: 85
edited November -1 in Working with GS (Mac)
Ok so we all remember super mario right? as an example, when the turtle ran into you, you would lose a life, and start from the checkpoint again, but if you where to jump ON it, you would kill it, is there a way to do something like this on GS

so if actor 2 walks into actor 1, you die, and if actor 1 jumps onto actor 2, actor 2 dies?

Comments

  • reddotincreddotinc Member Posts: 653
    You would need to set different hit markers on actor 2.

    1 for the front/back, and 1 for the top.

    Then you can set if actor 1 collides with front/back then X, and if actor 1 collides with top then Y.

    // Red Dot Inc
  • HachikoHachiko Member Posts: 330
    actually, there's a way that doesn't need two actors with relative constrains.
    what I use, and works perfect, require the use of instances or only one constrain.

    If you use instances, on the monster:
    Rule
    "when actor collides with Hero"
    Rule
    if hero self.position Y is greater than self.position Y of the monster + self height / 2 of the monster

    Put in here rules that kill the monster

    Otherwise

    put in here rules that kill the hero

    With only prototype, you need to constrain attribute self.position Y to a game attribute, so that the foes can see the Y position of the hero. In this constrain, you can have something like
    constrain game.positionYofHero to self.positionY-self.height of the hero / 2, so that actually the Y the game check's is the one at the feet of the hero, and not at the center of him, so it's easier to think about the correct "greater and less" to check if it's on top of the monster or not.
    Everything else is basically the same.
    With instances, there's a constrain less, always good for perfomance.
  • AtlantenAtlanten Member, PRO Posts: 56
    Constraints take a big toll on performance so here's another way you might want to try:

    Check if player is moving down through the air. As in

    If [self.Motion.Linear.Velocity.Y < 0] AND [if actor collides with Actor 2] then kill monster.

    That means, if you're jumping and colliding with the enemy then you'll kill it. It also means you won't kill it if you jump just before it and hit it on the way up. Which I believe is the way Mario works too.
  • charlieaf92charlieaf92 Member Posts: 84
    Atlanten said:
    Constraints take a big toll on performance so here's another way you might want to try:

    Check if player is moving down through the air. As in

    If [self.Motion.Linear.Velocity.Y < 0] AND [if actor collides with Actor 2] then kill monster.

    That means, if you're jumping and colliding with the enemy then you'll kill it. It also means you won't kill it if you jump just before it and hit it on the way up. Which I believe is the way Mario works too.

    If you come down short you may still get the kill in this scenario though. It will largely depend on the shape of the enemy ... if they are tall then it likely won't work. If they are short then you could probably get by but I would test it and see if it meets your standards.

    When I made a platform I used the compare the lower Y of the actor and the top Y of the enemy method and built in a slight buffer because the actor was moving more than 1 pixel per frame.
Sign In or Register to comment.