How to use a picture partly as obstacle
Hi everyone,
It's a bit hard to explain what I want to do, but I'll try with the help of some images. I'm trying to make a Zelda-like game, which means it has a character that can be moved in more than 2 directions. Here is my problem. For example, it has a tree and the character moves in front of the tree. The following happens:
http://www.shakifanatico.com/files/zelda_wrong.jpg http://www.shakifanatico.com/files/z...g_obstacle.jpg
The character can't move more upwards to the tree. In the second image above you can see why. The tree is a whole obstacle and the lowest pixel of the tree is exactly where the collision starts.
I would like the tree to be partly an obstacle, like this:
http://www.shakifanatico.com/files/zelda_good.jpg http://www.shakifanatico.com/files/z...d_obstacle.jpg
The second image above shows where the collision should start. Of course I could cut the tree in two parts and treat one part as obstacle and the other as a simple background, but I'm sure there must be a much easier way to do this.
I've tried everything with hot spots and action points on the character and also on the tree itself as background and active object.
Any help would be appreciated! Thanks!
Re: How to use a picture partly as obstacle
Or you could treat the tree as backdrop and have an extra hidden object, with a simpler shape, that acts as the obstacle.
Re: How to use a picture partly as obstacle
I would say that the easiest way is to think of it the other way round, and have a player-controlled invisible "collision box" that is placed where the feet of the player would be. Then continually set the position of the visible Link sprite relative to the position of this collision box.
Re: How to use a picture partly as obstacle
Thanks for your answer Sarah. I think a solution involves the character itself. For example, your solution won't work if the item is smaller than the character.
I think the character should have a collision detection in its center that would automatically work with all obstacles. Although that won't work with approaching an item from above either.
Re: How to use a picture partly as obstacle
Thank you DavidN. I was also thinking of the other way around, but I don't have much experience with a player-controlled invisible collision box. I would appreciate it a lot if you could explain me more about how to do it.
Re: How to use a picture partly as obstacle
I can do you up an example if you like - I'll put it in the File Archive when I get home this evening...
Re: How to use a picture partly as obstacle
Quote:
Originally Posted by DavidN
I can do you up an example if you like - I'll put it in the File Archive when I get home this evening...
That would be great, thank you!
Re: How to use a picture partly as obstacle
Here it is:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=47760
Most of it should be self-explanatory. In addition to the collision box, I've split the backdrop objects over two layers so that the top half always appears in front of the player. (Although I think that in SNES Zelda, the example you gave, there aren't any backdrops that you can walk behind anyway.)
Re: How to use a picture partly as obstacle
Quote:
Originally Posted by DavidN
Here it is:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=47760
Most of it should be self-explanatory. In addition to the collision box, I've split the backdrop objects over two layers so that the top half always appears in front of the player. (Although I think that in SNES Zelda, the example you gave, there aren't any backdrops that you can walk behind anyway.)
It works perfectly, thank you very much! I think your tutorial file will be useful to many people. Thanks again! :)
Re: How to use a picture partly as obstacle
This is already an old thread, but I'd like to add a little trick to let your character also walk behind objects (an easy way to get a collision mask, without extra objects).
It goes like this:
Let's assume your tree has an animation "stopped", and direction "right" contains the picture of the tree.
Now add a direction "down". Copy your tree there, so the size is correct and the hotspot is the same. Now cut everything away except for the base of the tree (that is probably an ellipse where the root touches the ground) - this will be what the character collides with.
Add your tree to a qualifier, in this example "Neutral", that you will use for all obstacles.
Add this event:
+ Start of frame
> Group Neutral > Set direction to down
> Group Neutral > Animation > Add backdrop as obstacle
> Group Neutral > Set direction to right
That's it! Now all objects with the neutral qualifier have an obstacle backdrop behind them! Together with DavidN's technique for the player's collisions you have very precise and easy collision detection.
Use the layer extension to sort all objects, so a tree is in front of a player, when he is "behind" it.