How do I animate objects or characters that don't move?

Started by Flint0, Mon 21/06/2021 16:14:51

Previous topic - Next topic

Flint0

I know that you can animate the background, but I would like to have more than 5 frames so I want to try by using a character or an object as a background or atleast for the small details like lights.
I have no idea how to animate characters when they are not moving and they are just standing (I know what the views are) and I have 0 idea of how to animate the objects.
I would thanks if someone can help, I have to say that I'm a noob with code so it would be nice if you explain it in the most easy way, for dummies. :tongue:

Matti

Using objects is the way to go if you want to animate parts of the background. I'm not sure what the problem is though, just use Object.Animate. Make sure that you use eNoBlock and also eRepeat in case it's supposed to be constantly animated.

Flint0

How should I do it? Adding: object.animate(viewname);  at the end of the global script? Also how do I refer to the object in the script? Because for example with the characters you can change the character name for the script like cname. But this option does not appear with the objects.

Matti

You can give the object a name via the object's properties panel at the lower right of the editor.

The code goes into the room's script, not the global script, like everything else that is room-related. If you want for example a constantly flickering light in a room, put oLight.Animate(loop, delay, eRepeat, eNoBlock) in the room_Load() function. If you want to make an animation to start at some later point, put the code where the condition is met to start the animation.

I named the object oLight, because an "o" is useful to indicate that it's an object, not something else.

On another note: Densming has made video tutorials for AGS on Youtube. You should check them out, they might help you a lot with the basics.

Flint0

Thank you,I've been triying to animate it but I still cannot do it and i don't know where the error is.
I am on the room1 script, wich is like that:

// room script file

function room_Load()
{
 
  olight.SetView(3);
  olight.Animate(0, 3, eRepeat, eNoBlock);

  clight2.Animate(0, 3, eRepeat, eNoBlock);
  }


I want to animate a character and an object, both look the same, the character is called clight2 and the object olight, I asigned the to all type of views of clight2 the view that has the animation of the light (animation3 and loop 0) and wrote this code but it still not working (both of them), also idk if this is how you asign the view to the object.

Slasher

With character you would use the Lockview command...

Code: ags

 clight2.Lockview(3);
 clight2.Animate(0, 3, eRepeat, eNoBlock);




Flint0


Slasher

Quote from: Flint0 on Tue 22/06/2021 11:49:19
I have it like that but it still not working  :sad:
Recheck the view/loops and names...

Did you just type in function Room_Load into the room script? My guess is you did... you need to click Room_Load in the room's properties panel which will enable that built-in function...

Crimson Wizard

#8
Quote from: Flint0 on Tue 22/06/2021 11:49:19
I have it like that but it still not working  :sad:

Please always clarify what does "not working" mean. Because "not working" may imply -
* Nothing happens,
* Something happens but not what you expect,
* Errors when compiling,
* Errors when running.


In regards to "room_Load", like Slasher mentioned room events do not run on their own, you have to bind them to events on the property pane.

Best way to test if your function runs at all is to add a Display command there, like: " Display("TEST"); ".

In the AGS manual there are tutorials on how to create simple games and add various interactions, I recommend reading these because they demonstrate most important basics:
https://adventuregamestudio.github.io/ags-manual/acintro3.html
Specifically note how do you bind events to functions.

Flint0

Ok I will check everything again, what didn't work is the animation, the game runs but the object does not animate.

Slasher

Quote from: Flint0 on Tue 22/06/2021 14:19:06
Ok I will check everything again, what didn't work is the animation, the game runs but the object does not animate.
Make sure each animation has minimum 3 frames...or it will not animate...repeat a frame to make 3 frames...

Snarky

I'm like 90% sure that the problem is what Crimson Wizard describes, that the function doesn't run in the first place because it hasn't been hooked up to the event:

Quote from: Crimson Wizard on Tue 22/06/2021 12:22:15
In regards to "room_Load", like Slasher mentioned room events do not run on their own, you have to bind them to events on the property pane.

Best way to test if your function runs at all is to add a Display command there, like: " Display("TEST"); ".

In the AGS manual there are tutorials on how to create simple games and add various interactions, I recommend reading these because they demonstrate most important basics:
https://adventuregamestudio.github.io/ags-manual/acintro3.html
Specifically note how do you bind events to functions.

Flint0

Okay, I didn't explain myself too well, I did what you told me, now when I click on them they animate correctly but I want them to animate without having to have any event on them, I just want them to animate when you enter the room so they are like an animated element of the background, maybe I know how to do it with the tutorials you told me on yt, I will try with that and tell to you if I need more help, thank you so much for the help.  :)

Crimson Wizard

#13
Don't connect this function to clicking on an object, connect it to the room's "Room before fade-in" event, that is a standard place to start anything in the room, it will run every time the room is loaded.

Flint0

Yeah, I already did it with that, thank you to everyone.  :grin:

SMF spam blocked by CleanTalk