Side collisions irk player

Non-platform specific questions.

Side collisions irk player

Postby sunnybubblegum » Fri Jul 08, 2011 7:11 pm

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!
Attachments
topdown.zip
Try running into a bush or a tree from the left or right.
(48.68 KiB) Downloaded 86 times
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: Side collisions irk player

Postby jimmynewguy » Fri Jul 08, 2011 9:02 pm

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
Attachments
Topdown.zip
(60.29 KiB) Downloaded 64 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Side collisions irk player

Postby sunnybubblegum » Sat Jul 09, 2011 3:15 am

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 :)
Attachments
Topdown.zip
(53.17 KiB) Downloaded 76 times
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: Side collisions irk player

Postby foleyjo » Sat Jul 09, 2011 12:31 pm

If your doing this in a collision event then refer to the plant/rocks as collide so only the collided one is used
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: Side collisions irk player

Postby jimmynewguy » Sat Jul 09, 2011 3:40 pm

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!
Attachments
data.zip
(52.29 KiB) Downloaded 83 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Side collisions irk player

Postby sunnybubblegum » Mon Jul 11, 2011 2:36 am

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!
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: Side collisions irk player

Postby jimmynewguy » Mon Jul 11, 2011 3:19 am

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.
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Side collisions irk player

Postby sunnybubblegum » Thu Jul 14, 2011 1:23 am

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?
Attachments
Topdown.zip
(3.4 MiB) Downloaded 80 times
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: Side collisions irk player

Postby jimmynewguy » Thu Jul 14, 2011 2:55 am

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.
Attachments
topdown.zip
(3.4 MiB) Downloaded 82 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Side collisions irk player

Postby sunnybubblegum » Thu Jul 14, 2011 2:56 pm

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!
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest