Page 1 of 1
Side collisions irk player
Posted:
Fri Jul 08, 2011 7:11 pm
by sunnybubblegum
When coming at a smaller-sized actor from the top or the bottom, the collide event stops your player's movement fully, as expected. However, when coming at it from the left or the right, unless you hit the exact center your player will get irked around the object.
In all of the platform game exercises I've tried so far, this results in the player climbing wall corners. In the current case I'm making a top down game, and the effect is very jarring. I've also noticed this in many of the other demos I've looked at.
I really hope there is a simple solution to this. Thanks in advance!
Re: Side collisions irk player
Posted:
Fri Jul 08, 2011 9:02 pm
by jimmynewguy
Here's one easy way of doing it top down style. But there's many.
I made an actor called player_collide that does all the moving and colliding for the player, he is just parented to it. This also makes it so the player's head doesn't collide with the bottom of things and make it look stupid.
Things you might want to add:
~ Make the view not parented to the player but still follow, then you can set boundaries for the view and not see the black outline of the world
~ Make all the plants clones instead of tiled actor then when its created set it's zdepth based on y-coordinate then on draw actor always update the players so he can go "behind" trees and bushes
PS: I like your graphics
Re: Side collisions irk player
Posted:
Sat Jul 09, 2011 3:15 am
by sunnybubblegum
Thank you bunches! I see what you've done here and it works a lot better all around. I just have another question based on your recommendations. I guess we're officially off-topic now.
Make all the plants clones instead of tiled actor then when its created set it's zdepth based on y-coordinate then on draw actor always update the players so he can go "behind" trees and bushes
I've now made all of the plants (and rocks) clones instead of tiles, and I've attempted to do what you described (added in 'player_collide' Draw Actor). It's *sort of* working, but I don't know how to get the plant/rock clones' z-depths changing individually.
And thank you for the compliment on the graphics :)
Re: Side collisions irk player
Posted:
Sat Jul 09, 2011 12:31 pm
by foleyjo
If your doing this in a collision event then refer to the plant/rocks as collide so only the collided one is used
Re: Side collisions irk player
Posted:
Sat Jul 09, 2011 3:40 pm
by jimmynewguy
Here, this should help.
The trees and bushes do not move, so we can set their zdepth when they are created. And the player_collide moves so we update it every frame.
We do y/100000 because even the tiniest difference in zdepth still registers. For the trees and rocks I added some to their y value in order to compensate for their height, so if you have other objects to add like them just play around with it until it looks good.
The stone wall and grass are set to -1 zdepth to the player is always in front of them (basically)
Keep up the good work and good luck!
Re: Side collisions irk player
Posted:
Mon Jul 11, 2011 2:36 am
by sunnybubblegum
Many thanks! I would have never known how to approach this issue.
I'm still trying to understand how the code you entered achieved the behind/in-front effect. My brain is looking for an 'if' statement somewhere saying "if player_collide's y-coordinate is higher than actor's" to establish when he's behind or in-front. Also, does 'DONT_DRAW_ONLY' draw him 'behind' an actor?
Nevertheless, it works great and I have time to understand it better. Thanks again and cheers!
Re: Side collisions irk player
Posted:
Mon Jul 11, 2011 3:19 am
by jimmynewguy
No worries, using GE is like anything in life. You're not born knowing how to do it, you have to learn.
The reason we don't need an if statement is because they don't interact with each other at all really. We're taking the y-coordinate of the actor and using it as the zdepth.
So let's say you're tree is "above" the player on the y-coordinate. Here we want to show it "behind" the player. In GE the y-coordinate gets smaller as you go "North" (or up) and larger as you go "South". So let's say the tree's y = 1 and the players y = 10. The tree will have a lower zdepth than the player and the player will appear to be in front of the tree. The tree does not move so we only have to set it's zdepth (aka check it's y coordinate) once when it is created. The player updates his every frame.
The DONT_DRAW_ONLY is for the player_collide actor only, it changes the visibility to be "invisible" but still allows it to collide like a normal actor. If we changed the transparency to 1 it would not collide.
Cheers, and good luck mate.
Re: Side collisions irk player
Posted:
Thu Jul 14, 2011 1:23 am
by sunnybubblegum
Alright I understand now. Good clarification!
I just wanted to ask you about the other recommendation you posted.
~ Make the view not parented to the player but still follow, then you can set boundaries for the view and not see the black outline of the world
I'm finally getting around to doing this, but it's more confusing than I thought it would be. I noticed you can't add collision events to the view, which was my plan. How would you get the view stopping at boundaries on your map?
Re: Side collisions irk player
Posted:
Thu Jul 14, 2011 2:55 am
by jimmynewguy
Here, try parenting the view to an actor that can collide. You will have to change some things though (I changed the view size because it was too easy for it to escape the boundaries). Go ahead and play with the view boundaries and doors to help fix them up a little and this should suit you well. It might be easier to add collisions to the grey walls instead of making a clone stop actor for each wall. But it still works.
Re: Side collisions irk player
Posted:
Thu Jul 14, 2011 2:56 pm
by sunnybubblegum
Very helpful. I will definitely play around with it and see what I can do. Although I had a fullscreen experience in mind (possibly even for the iPad), I almost prefer your 640x480 framing. I'll think about what I want and find a happy medium.
I really appreciate all of your assistance and modifications throughout this thread. Wish I could give you more one-ups!