[SOLVED] character not player to walk back and forth

Started by zeta_san, Thu 20/01/2022 21:10:30

Previous topic - Next topic

zeta_san

Hi everyone

I would like a character (a bird) not player to walk back and forth in a loop

I created the loop
I created the character

thank you

Rik_Vargard

#1
I hope this helps you (means your bird has to be an object i think)  > https://www.adventuregamestudio.co.uk/forums/index.php?topic=50145.0

zeta_san


Pax Animo

#3
Quote from: Rik_Vargard on Thu 20/01/2022 21:44:46
I hope this helps you (means your bird has to be an object i think)  > https://www.adventuregamestudio.co.uk/forums/index.php?topic=50145.0

From my understanding, it doesn't have to be an object, you'll be most likely better off using a character as characters act in many ways like objects but without certain restrictions.
Misunderstood

eri0o

#4
if it's a character you can just pass WalkWhere property to be eAnywhere when the character is walking, to ignore walkable areas.

An example can be like this, adding this code in your room script - this makes the bird walk randomly though, not sure exactly what you want, if the character has a route, check in which point of the route it is, then make it walk to the point it makes sense (if it's at point A, walk to B, if it's in point B, walk to A, if it's in neither, don't tell nothing)

Code: ags
void repeatedly_execute_always()
{
  if(!cBird.Moving) {
    cBird.Walk(Random(Room.Width) /* full room */,
               Random(50) /* only top to 50 px */,
               eNoBlock /* can't block on rep exec always*/,
               eAnywhere);
  }
}

zeta_san

Thanks everyone you are fantastic! this forum doesn't make me feel alone ..

I modified it like this.

Code: ags
function room_RepExec()
{
 if(!cMerlo.Moving) {
    cMerlo.Walk(Random(Room.Width) /* full room */,
               Random(50) /* only top to 50 px */,
               eNoBlock /* can't block on rep exec always*/,
               eAnywhere);
}}


for a path from 50 to 150 and 150 to 50, should it be removed randomly?

AddWaypoint?

if(!cMerlo.Moving) { 
cMerlo.Walk(16, 123);
cMerlo.AddWaypoint(1, 123);

zeta_san

function room_RepExec()
{
if(!cMerlo.Moving)

{
cMerlo.AddWaypoint(36, 129);
cMerlo.AddWaypoint(18, 129);
}}

:grin:

Thanks

Cassiebsg

Please not that when you place the code in RepExec instead for repeatedly_execute_always(), your bird will stop whenever there's a blocking action going on, like your character walking in a block mode or talking... so, if you wish your bird to not freeze mid flight while your player character is chatting or doing something in blocking mode, I suggest you use repeatedly_execute_always().  ;)
There are those who believe that life here began out there...

newwaveburritos

It also might be worth mentioning that it's probably worthwhile to keep your code formatted so it's easy to read.  You might have done this that way just for the forum post but the more cod you get together the harder it will be to read.  Keeping the curly braces separate will help you distinguish where the if statement ends and where it is in the function especially if you have more than one.  Just a thought.  Good luck with the project!

SMF spam blocked by CleanTalk