My character walks through things and characters! How to avoid? (SOLVED!)

Started by Clarabella, Sun 24/02/2008 19:43:19

Previous topic - Next topic

Clarabella

I just want my characters walk around other characters and objects, when they found them on their way, and don't go straight and through people/things.

I did a forum search, and I found that I have to turn on "solid" property of the characters, to avoid they walk though each other... I did it, for both characters, but it didn't work! Is it possible? They go on walking though each other. Is there something else I missed?

I also found interesting functions that would help: character.BlockingHeight and character.BlockingWidth, but I didn't understand how and where to use them in the script.
Do I have to put them inside a function {}? And, if yes, what kind of function? Or do I have to declare them in some way, just like variables and such things?

Thanks!

(PS: consider I don't have any experience of C and/or other programming languages... I'm learning something of programming with ags for the first time... and I'm enjoing a lot  ;D.. except when I don't understand how to make things work  >:( so, sorry if these questions seem extremely easy and stupid to you)

ShiverMeSideways

You got the Solid property right, but you applied it to the character instead of the object. The object needs to be solid so the character avoids it. If this still doesn't work, make the character solid too. That should do it.

Clarabella

But everything is set "solid" in my game...
I have this two characters, let's name them 1 and 2.
1 is set solid: true.
2 is set solid: true.
But 1 still walks through 2. I can't understand why...

Khris

Do this simple test: during the game, press Ctrl-A. This should display the walkable areas. Every solid character/object is supposed to remove a rectangle shaped piece of the areas, located at his feet/its base.

.BlockingWidth/Height can be set e.g. in the room_Load function (create it using the room's events pane).
Characters are global, so you can set theirs inside game_start, too.
Use something like
Code: ags
  cJoe.BlockingWidth = 20;

Matti

It seems your character's sprite is longer than the character itself - the feet aren't at the bottom of the sprite. But Khris suggestion should do it..

Clarabella

Yeah, infact it helped. Now it works!
And I also understood how to use that scripts!  :D

Thank you Khris, and thanks everyone for help.

SMF spam blocked by CleanTalk