Collision box, need help

Hello everybody,

I am creating a little game, and I have an issue.
http://www.casimages.com/img.php?i=140102061219169691.png

I have designed that thing that grows down to crush my main character when it collides with that thing. But the problem, as you can imagine, is that as soon as the main character touches the images, even the transparency, the scene resets. I want the scene to reset only when the character is crushing by the extremity of the thing. How can I do that ? In fact, I would need an actor which would follow the X and Y of the extremity of the thing, but how can I do that ?

Thank you

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You need to make sure there is no extra space in the image file below the visible portion of the "thing." Or, you can just code it so that the main character actor is only affected when it collides with the "thing" and the y position of the "thing" is below a certain value. You would need to constrain a real game attribute (game.ThingY) to the "thing" actor's self.position.Y.

    Think of a name so we don't have to keep calling it "thing"! :P

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • silviossilvios Member Posts: 29
    Thank you Tatiang. We can call it the roll. I cannot cancel the extra space on the image,, because the others are bigger, and I need that to animate the roll.

    So i am gonna use your second option, but could you give me all the exact rules please, because I do not understand every things :/ Thank you !
  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291
    edited January 2014
    @silvios,
    Going off of what @tatiang is saying in regards to making sure there is no extra space in the image file below the visible portion. You can check that by putting the image of the "thing" in a photo editor software such as photoshop then make sure there is no extra canvas space or invisible background around the image of the "thing". Make sure it is cropped to the exact dimensions of the "thing".

    You could also create a custom hit box. Create an invisible actor and constrain it to the "things" x and y and say when player collides with custom hit box then game over.
  • silviossilvios Member Posts: 29
    Thank you KillerPenguin, but as I said, I cannot delete the extra space, because the images that I use in the animation are bigger, and if I delete the extra space in the first, the other images will be cropped at the size of the first image.

    I have tried the solution of Tatiang :

    Create attribute Roll.Y
    I went on the Roll : constrain attribute game.RollY to self.positionY

    After I went on the character : When actor collides with Roll
    and when attribute game.RollY < 360

    then : reset scene

    But nothing happens :/
  • silviossilvios Member Posts: 29
    I tried your solution KIllerPenguin, but the Roll disappears :(
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Put a display text actor in your Roll actor and add self.position.Y to the expression editor. Preview and check to see that it actually gets below 360. Then do the same thing with game.RollY to check its value and make sure the constrain is set up properly.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • silviossilvios Member Posts: 29
    Ok thank you.

    I did that, and in both cases, the display text says that the Y position is 418, even when there is the animation playing.

    I think that all the images in the animation have the same Y position, because they have the same size than the first image, without so much extra space.

    I don't know what to do :(
  • BBEnkBBEnk Member Posts: 1,764
    are you animating the crusher coming down? if so you could just use one single image and have that image move up / down that way theres no space.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yes, if you're not moving the actor but just animating the illusion of movement then the y position won't change at all.

    You'll need to constrain an invisible actor to the Roll actor and have it move up and down in sync with the animation. Then create a rule on your main character actor that checks for collision with the invisible actor. Unless the main character can jump, I'd make the invisible actor a somewhat thin rectangle the width of the Roll and constrain it to the bottom of the actor (game.RollY - [half of the height of the Roll actor] +/- a small offset if needed).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • silviossilvios Member Posts: 29
    Thank you BBEnk : what the rule to make move and down my image and loop that ?

    Thank you Tatiang, i am gonna test
  • silviossilvios Member Posts: 29
    I finally manage to do that with an interpolate ! Thank you BBEnk !

    Thank you also Tatiang but your solution was a bit hard for me ^^
  • SocksSocks London, UK.Member Posts: 12,822
    @Silvios

    It's much easier just to move the object:

    Link: https://www.mediafire.com/?0ditr31pyynylpa
  • silviossilvios Member Posts: 29
    I have an ultimate question about this project :

    I want that thing to rotate from this position : http://hpics.li/1a1dd58
    to that position : http://hpics.li/7a6e974

    I have tried with Interpolate the rotation, but the gravity center of this object is at the center, not at the top, so it does not work. How can I do ? Thank you
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    That rope is attached at two different points!

    You may want to read some of the off-center rotation threads on the forums.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @tatiang
    That rope is attached at two different points!

    You may want to read some of the off-center rotation threads on the forums.

    I think it is just a rotation about a natural centre point, i.e a simple rotation . . . ?
  • silviossilvios Member Posts: 29
    I have read some threads, but I do not get everything...

    Indeed, I want my actor to rotate like that :
    http://videobam.com/BxKOL

    So if you have a solution...
  • SocksSocks London, UK.Member Posts: 12,822
    Indeed, I want my actor to rotate like that :
    http://videobam.com/BxKOL
    Constrain rotation to . . . . 30*sin( game.Time *100)+30

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If it's a circular actor then yes, no need for off-center rotation.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • silviossilvios Member Posts: 29
    edited January 2014
    Thank you, so when I do that, the movement is good, but the things only goes to the right. http://videobam.com/WsGLj
    I want it to do the same movement in left direction, which is : -(30*sin( game.Time *100)+30)

    But how I can tell GameSalad to do both movements ? TY
  • SocksSocks London, UK.Member Posts: 12,822
    Thank you, so when I do that, the movement is good, but the things only goes to the right. http://videobam.com/WsGLj
    I want it to do the same movement in left direction, which is : -(30*sin( game.Time *100)+30)

    But how I can tell GameSalad to do both movements ? TY
    Adjust the values in the equation.
  • silviossilvios Member Posts: 29
    I have already tried, but I do not know how values I have to put...
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    I have already tried, but I do not know how values I have to put...

    If you change each value, one at a time, you can see what they do.

    I used your artwork where the ball was at an angle, if you are using an artwork where the ball is not at an angle then try getting rid of the offset . . . . which is the '+ 30' part.

    30*sin( game.Time *100)
  • silviossilvios Member Posts: 29
    I have tried, but i cannot find what value define the angle of the rotation. I know that we can change the speed, I swear I have tried
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    I have tried, but i cannot find what value define the angle of the rotation. I know that we can change the speed, I swear I have tried
    Ok, you know what the speed is, that only leaves one other value, try that one !

    :)) ;)

    AAA*sin( game.Time *BBB)+CCC

    AAA = how much swing
    BBB = speed
    CCC = offset
  • silviossilvios Member Posts: 29
    When I change the AAA it swings more, but in right direction, not in left :(
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    Can you post a picture of the actor that swings.

    Can you also post the exact equation you have tried.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Here are some principles:

    1) All actors start out with a rotation of 0 degrees. In GameSalad, 0 degrees is pointing directly to the right ---->. Make sure your graphics start out pointing in the same direction. That is, the graphic should be made so that it is also pointing to the right. For your graphic, the rope should be on the left, and the ball on the right, like this: -----O. If you do this, its makes it much easier for you to keep track the real rotation of the actor, instead of the apparent rotation of the graphic.

    2) In GameSalad, an actor points downwards at 270 degrees. So you need to rotate your actor to 270 degrees to get it to point straight down.

    3) The equation @Socks gave you uses the sin() function to get things to oscillate back and forth. Its perfect for what you want. The rest of the numbers just make it oscillate to the degree, and direction, and speed you want.

    4) Use this formula: 270+45*(sin( self.Time *200))
    270 means straight down
    45 is how many degrees to to make the ball swing to the left and right of 270 (so it will swing from 315 degrees to 225 degrees, passing 270 in the middle)
    200 is the speed you want it to oscillate, you can change that to whatever you want

  • SocksSocks London, UK.Member Posts: 12,822
    What @RThurman said . . .

    :)>-
  • silviossilvios Member Posts: 29
    Thank you so much for the explanations ! I would have never got it by myself! Thanks
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @silvios -- you are welcome. Hope it works for you.

    @Socks -- sorry to interlope. Couldn't resist for some reason. :D
Sign In or Register to comment.