Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GazJ on Wed 30/07/2008 22:47:11

Title: How can I stop my character walking through objects?
Post by: GazJ on Wed 30/07/2008 22:47:11
I have started a new game and having checked through the manual I wondered if anyone has an answer to this problem.

Let's say I have a barrel object so I don't want my character to appear to walk over it or through it.

I know I can make the area at the base of the barrel a 'non-walkable area'.  But the barrel can be picked up and moved to another area in the room.  This will then leave an empty area in the room that my character cannot walk on.

I am new to AGS game making so any ideas would be gratefully received.
Title: Re: How can I stop my character walking through objects?
Post by: zabnat on Wed 30/07/2008 23:11:05
Make sure the barrel object is Solid (Object.Solid in manual) (Also make sure that your character is Solid too). Then use objects BlockingHeight and BlockingWidth to determine how large of a are you'll want to block with the barrel. Good tip for setting the area is to set these to some estimate and then test the game, press Ctrl+A to see the walkable areas to see if the object is blocking enough and then change the values accordingly.
Title: Re: How can I stop my character walking through objects?
Post by: Matti on Thu 31/07/2008 15:40:19
Quote from: GazJ on Wed 30/07/2008 22:47:11
I know I can make the area at the base of the barrel a 'non-walkable area'.  But the barrel can be picked up and moved to another area in the room.  This will then leave an empty area in the room that my character cannot walk on.

This wouldn't be a problem since you could just make a walkable area appear after the barrel is taken.

But better do what zabnat said, it's easier..
Title: Re: How can I stop my character walking through objects?
Post by: GazJ on Sun 03/08/2008 18:10:10
Thanx for that.  Thats solved that problem.

But I am still having a problem with this:

Basically I have a square hole in the ground and I don't want the character to stand or walk over it.
I have set the baseline to 150 which is in the middle of the hole.  I have then set the BlockingHeight and BlockingWidth to  cover the entire area of the hole.
But when I come to run the game the Baseline has been put at the bottom of the hole object.

I have set the hole's baseline in the editor and in the room's FirstLoad script.

Any ideas on what I am doing wrong?
Title: Re: How can I stop my character walking through objects?
Post by: zabnat on Mon 04/08/2008 08:17:25
Sadly IIRC the object baseline does not affect the BlockingHeight.
To remedy this, you could draw another walkable area (different id) over the hole and then use RemoveWalkableArea() and RestoreWalkableArea() accordingly. So this is what matti suggested but in more detail.
Title: Re: How can I stop my character walking through objects?
Post by: Khris on Mon 04/08/2008 11:35:16
The baseline doesn't affect the BlockingHeight, but it determines its center.

During the game, press Ctrl-A to look at the actual walkable areas.

QuoteBut when I come to run the game the Baseline has been put at the bottom of the hole object.
How did you find that out? Are you sure the baseline has moved?

I can only think of a player.z setting != 0 or player character sprites not properly cropped.
Title: Re: How can I stop my character walking through objects?
Post by: zabnat on Mon 04/08/2008 12:12:06
Quote from: KhrisMUC on Mon 04/08/2008 11:35:16
The baseline doesn't affect the BlockingHeight, but it determines its center.

During the game, press Ctrl-A to look at the actual walkable areas.
With affecting BlockingHeight I meant that it would (should) determine its center. So the setting BlockingHeight to 20 and baseline to 10 the object should block a area from top of the screen to 20 pixels from the top of the screen, yes? And by referring to manual you could get the impression that this was the case, but it's not. I actually just tested it again and the objects baseline setting doesn't affect the place where object places its blocking chunk, it only affects whether character is drawn on top of the object or behind. I'm not sure if this is a bug or not, but this seems to be the case. The baseline used for blocking is always at the bottom of the object.

If you have a tip to overcome this I too would like to hear it, as it has been bothering me occasionally.
Title: Re: How can I stop my character walking through objects?
Post by: GazJ on Wed 06/08/2008 19:30:49
Thanks for all your advice I have solved my last problem with the hole in the floor object.
I used a seperate walkable area over the hole which is removed when the hole appears which is what Matti suggested.
It does seem to be that the baseline is always placed at the bottom for Blocking which is not what I wanted for this hole object I wanted it in the centre.
Title: Re: How can I stop my character walking through objects?
Post by: Khris on Wed 06/08/2008 23:20:58
CJ answered that this is by design, and while I understand the reasoning, it's clear that there are occasions where one would want a different behavior.
Off the top of my head, use a second, invisible object (.Transparency = 100;) to generate the actual hole in the walkable area.
(As was mentioned, this isn't necessary if the blocking thing won't get moved around but the only way to do it if it will.)