An animation problem that should be easy to fix... but I don't know how

Started by Chomba, Wed 25/11/2020 05:54:30

Previous topic - Next topic

Chomba

Hello again,

I'm having a problem that I can't find a way to solve.
In theory I know how it should be, but I can't put it into practice and I can't find precise information or information that I can understand to solve it.

This is the problem:

I want to put a glowing point (I already have the animation) that blinks from time to time to point out to the player that there is something of interest in that specific place, until he interacts with it and then the character picks up an object, so the glow should stop appearing from there on.

My idea was to put an object, animate it using the View of the bright point and using a boolean make it disappear when the object is picked up. But for some reason I can't make it glow even once.

I'm using a code something like this for the animation:

Code: ags

function room_Load()
{
 oObject.SetView(X);
 oObjet.Animate(0, 3, eRepeat, eNoBlock);
}


Also, I don´t know how to make a certain time go by without pausing the game, since the use of Wait, as I understand it, pauses everything until the counting finsishes.
Anyway, that code is not working for me...

In the room already, there is a cutscene when the game starts (it's the first room), and where I have an action to perform each time it enters the room again (it's the animation of when it enters from the other side, it's just two rooms)

I know it shouldn't be complicated, but I can't solve it

Khris

Did you type that entire function into the room script? Because like almost all other event functions, AGS will only call it if it's actually linked to the event.
In the room's event pane (lighting bolt icon), does it say "room_Load" next to "Enters room before fade-in"?

As for the timing, you need a timer.
Code: ags
function room_Load()
{
  oObject.SetView(X);
  oObject.Animate(0, 3, eOnce, eNoBlock);
  SetTimer(1, GetGameSpeed() * 3);  // next animation in three seconds
}

function room_repExec()
{
  if (IsTimerExpired(1) && oObject.Visible) {
    oObject.Animate(0, 3, eOnce, eNoBlock);
    SetTimer(1, GetGameSpeed() * 3);  // next animation in three seconds
  }
}


room_repExec is also an event function and needs to be linked in the room's event pane. Just press the [...] button next to "Repeatedly_execute".

You also don't need a boolean to indicate that object got picked up. Just call  oObject.Visible = false;

Chomba

Quoteroom_repExec is also an event function and needs to be linked in the room's event pane. Just press the [...] button next to "Repeatedly_execute".

Oh shoot! that was it! I feel like an idiot. I just typed it in the script without doing the link...

QuoteYou also don't need a boolean to indicate that object got picked up. Just call  oObject.Visible = false;

You are totally right, I was overthinking how to handle that part!


I applied everything you said and it worked just fine!

Thanks Khris! I owe you a lot!

SMF spam blocked by CleanTalk