Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SestunaShadow on Wed 30/12/2015 14:11:34

Title: [Solved] Always animate character issue.
Post by: SestunaShadow on Wed 30/12/2015 14:11:34
Hello all of you,

Sorry for the inconvinience, i tried to look through the help file, tutorials and the wiki, but i can't make this function to work, the game launches normally but the character i want to always animate doenst do it. So as a last resort Im going to ask here for help.

Code (ags) Select

function game_start()
{
  cChar1.LockView(4);
  cChar1.Animate(1, 3, eRepeat, eBlock, eForwards);
  cChar1.UnlockView();
}


So, where i failed?

Thanks
Title: Re: Always animate character issue.
Post by: Slasher on Wed 30/12/2015 14:49:12
i think this may need to go in Room Load plus cChar1.UnlockView(); will never happen because animation is eRepeat and eBlock.
Title: Re: Always animate character issue.
Post by: SestunaShadow on Wed 30/12/2015 15:27:35
Oh, thanks, Room_Load seems more logical. but still doesn't work. the main character can move freely but the npc is still unanimated.

I tried the following functions.

Code (ags) Select

function Room_Load()
{
  cChar1.LockView(4);
  cChar1.Animate(1, 3, eRepeat, eBlock, eForwards);
}


Code (ags) Select

function Room_Load()
{
  cChar1.Animate(1, 3);
}


Code (ags) Select

function Room_Load()
{
  cChar1.Animate(1, 3, eRepeat, eBlock, eForwards);
}


the View is well put, if i change the main character to that one, when i move the animation works. But maybe its a propietries issue.
Title: Re: Always animate character issue.
Post by: Slasher on Wed 30/12/2015 16:46:26
if the npc is an object try Setview rather than Lockview else Changeview and it should be eRepeat eNoBlock.
Title: Re: Always animate character issue.
Post by: SestunaShadow on Wed 30/12/2015 17:19:36
It isn't an object i made him a character, I tested the lines on an interact with the character and there it works, i still cannot make it work auto though, the room_Load function doesnt work if it's the first room or maybe because the npc is a character the function has to go in the global script?

Sorry for asking so much :embarrassed:
Title: Re: Always animate character issue.
Post by: NickyNyce on Wed 30/12/2015 17:34:31
Try using frame 0 instead of 1. Perhaps you're using the wrong frame?

Place your code in Before fade in of the rooms script. And if the character is always animating, use eNoBlock.
Title: Re: Always animate character issue.
Post by: Slasher on Wed 30/12/2015 17:47:20
Quotemaybe because the npc is a character the function has to go in the global script?
only if you interact with him like: look, talk, use inv..
Title: Re: Always animate character issue.
Post by: SestunaShadow on Wed 30/12/2015 17:57:11
Ok, i feel so dumb now.

I don't know why when i write the code directly to the room script it doesn't work, but when i use the ags inteface and make an event before fade in then it works and the code is the same i think.

Code (ags) Select

function room_Load()
{
  cChar1.Animate(1, 3, eRepeat, eNoBlock, eForwards);
}


With this one now it works fine.

Welp, thank you all
Title: Re: [Solved] Always animate character issue.
Post by: Slasher on Wed 30/12/2015 18:05:20
Quotedon't know why when i write the code directly to the room script it doesn't work, but when i use the ags inteface and make an event before fade in then it works and the code is the same i think.
Let that be a lesson for you.. Glad you got it sorted ;)

if you make your own functions then you write them directly into the script.
Title: Re: Always animate character issue.
Post by: Khris on Wed 30/12/2015 21:29:57
Quote from: SestunaShadow on Wed 30/12/2015 17:57:11I don't know why when i write the code directly to the room script it doesn't work, but when i use the ags inteface and make an event before fade in then it works and the code is the same i think.

Easy: because AGS doesn't care about the function unless you actually link to it. There are exceptions* to this rule, but all the events listed in the respective event panels need to be linked to the functions for the functions to be called.

Using the "correct" name while adding the function yourself will not work. Plus, you used Room_Load instead of room_Load, which to AGS are two separate functions. So even if AGS worked that way, which (as the manual's tutorial explains) it doesn't, it wouldn't have worked due to the capital "R".
Btw, you can use completely custom names, or link multiple events to the same functions. Since AGS simply calls the function stated next to the event, the name used by default is just that, but not binding.

*Since I mentioned them, exceptions for room scripts are: on_call, on_mouse_click, on_key_press, repeatedly_execute_always.