Collision box, need help
silvios
Member Posts: 29
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
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
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
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 !
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.
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
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
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
Thank you Tatiang, i am gonna test
Thank you also Tatiang but your solution was a bit hard for me ^^
It's much easier just to move the object:
Link: https://www.mediafire.com/?0ditr31pyynylpa
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
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
I think it is just a rotation about a natural centre point, i.e a simple rotation . . . ?
Indeed, I want my actor to rotate like that :
http://videobam.com/BxKOL
So if you have a solution...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
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)
)
AAA*sin( game.Time *BBB)+CCC
AAA = how much swing
BBB = speed
CCC = offset
Can you also post the exact equation you have tried.
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
>-
@Socks -- sorry to interlope. Couldn't resist for some reason.