I made the doors of my map with animated models and now I want to play the animation when I open them but I have no idea what function to use. I tried this functions but I don't know how to use them or if they are what I need.
It isn't working. I think it's because I made a xanim instead of an animtree because the plugin let me port xanims. Is it possible to make it with xanims? Or do I have to make it with an animtree? Sorry for my ignorance.
init(){ objects = getentarray("name", "targetname");//replace name with targetname kvp array_thread(objects,::PlayMyAnim); }
#using_animtree( "nameofanimtree" );//replace nameofanimtree with the atr you have the anims in PlayMyAnim(){ //for your doors, maybe set up trigger as target of model to animate trig = getent(self.target,"targetname");//if one trig controls multiple doors, then getentarray and put the rest in another function and array thread it while(1){ trig waittill("trigger",player); //other door stuff here maybe checking for cost self UseAnimTree(#animtree); self SetAnim(%openanimname);//this method replace openanimname with your animname that opens the door //if you are doing those doors, you would set the model of the open door here that you will play the close door on wait( getanimlength( %openanimname ) ); self setmodel("opendoor");//change opendoor to open door model to play close anim on self clearanim( %openanimname, 0 );//stops anim while(player istouching(trig) || trig OtherPlayersTouching()) wait(.1); //make a function to make sure no other players are touching it either called OtherPlayersTouching or whatever self SetAnim(%closeanimname);//this method replace closeanimname with your animname that closes the door wait( getanimlength( %closeanimname ) ); self setmodel("closedoor");//change back to model that you use for a closed door self clearanim( %closeanimname, 0 );//stops anim } }
I'm not sure how you plan to script everything how you are going to do your doors, maybe with a trigger multiple, but that is how I kind of scripted the example above. Also assuming they are looping anims
Edit: You'll have to compile your patch of course before building your mod if you made changes to your animtrees
Last Edit: September 30, 2015, 07:23:30 pm by MakeCents
It isn't working. I think it's because I made a xanim instead of an animtree because the plugin let me port xanims. Is it possible to make it with xanims? Or do I have to make it with an animtree? Sorry for my ignorance.
For the animtree it is very simple, go to raw/animtree and I suggest using generic_human.atr Edit generic_human.atr with notepad++ and add your animation name in it
If the animation is not in any animtree then it won't work
I'm using MakeCents script and I think I've made the animtree properly, but when I'm loading the map the game crashes and throws this error:
Code Snippet
Plaintext
Loading fastfile 'aaa_patch' used 1.25 MB memory in DB alloc Database: Assets Sync Finished Loading fastfile aaa Loading fastfile 'aaa' used 74.50 MB memory in DB alloc Waited 1154 msec for asset 'maps/aaa.d3dbsp' of type 'col_map_mp'. - R_Cinematic_BeginLostDevice()... DB_BeginRecoverLostDevice()... R_ResetModelLighting()... R_ReleaseAllModels()... R_ReleaseLostImages()... Material_ReleaseAll()... R_ReleaseWorld()... Recovering lost device... R_ResetDevice()... Initializing render targets... Requested frame buffer to be 24-bit color with 8-b
Unhandled exception caught
Don't know what it means... I compiled the map, the patch and built the mod. ???
I don't know what that means either, without more info. Just out of curiosity, did you include the animtree in your csvs if you made a new one or did you add to an existing animtree like bwc said?
Code Snippet
Plaintext
rawfile,animtrees/animatreename.atr
Last Edit: September 29, 2015, 07:32:14 pm by MakeCents
I don't know what that means either, without more info. Just out of curiosity, did you include the animtree in your csvs if you made a new one or did you add to an existing animtree like bwc said?
Code Snippet
Plaintext
rawfile,animtrees/animatreename.atr
I made my own atr (I didn't know where to add my anims in the generic human file). And, of course, I didn't include it to my csv. I can't get used to those csv files. Anyway, I've just included it and it isn't working neither.
I made my own atr (I didn't know where to add my anims in the generic human file). And, of course, I didn't include it to my csv. I can't get used to those csv files. Anyway, I've just included it and it isn't working neither.
I think I've included all the necessary things, so it's prob just something simple yet, either prefab setup or you didn't make another function that checked if a player was touching the trig or something along those lines. If this is your first time doing something along these lines I woulds start by getting a test one do just loop without being triggered. Something like:
init(){ objects = getentarray("name", "targetname");//replace name with targetname kvp array_thread(objects,::PlayMyAnim); }
#using_animtree( "nameofanimtree" );//replace nameofanimtree with the atr you have the anims in PlayMyAnim(){ //for your doors, maybe set up trigger as target of model to animate trig = getent(self.target,"targetname");//if one trig controls multiple doors, then getentarray and put the rest in another function and array thread it while(1){//may not need loop if anim is looping self UseAnimTree(#animtree); self SetAnim(%openanimname);//this method replace openanimname with your animname that opens the door wait(2);//if no loop needed no wait needed } }
Once you get the anim in game and have it working on a script_model continue to the next step of setting up a trigger and making the trigger activate the anim, then set the model and so on.
If you just add it to the beginning of generic_human it should work also without including it. Paste the code you modified in here so I can make sure you changed all the placeholders I put in there and stuff. If you are getting errors, please add an image of that too from developer 1.
Last Edit: September 29, 2015, 08:02:39 pm by MakeCents
If you want scripts / features made for you, then contact me by PM or email / skype etc it will cost you tho so if you have no intention of reciprocating don't even waste my time
For the animtree it is very simple, go to raw/animtree and I suggest using generic_human.atr Edit generic_human.atr with notepad++ and add your animation name in it
If the animation is not in any animtree then it won't work
or, if its just a anim on a model, not a player or ai
just a blank notepad doc, paste you anim in. Save
done lol
do we not need this though?
#usAnimTree( animtree )
at the top ( i forget the exact wording for it )
Code Snippet
Plaintext
#using_animtree( "anim tree name" );
Last Edit: September 29, 2015, 08:13:48 pm by Harry Bo21
#using_animtree( "animtree name" );// change animtree name to the name of the atr
prior to the function that uses:
Code Snippet
Plaintext
self UseAnimTree(#animtree);
I use 4 animtrees in one gsc with this method that handles all my animations for script_models based on kvps. Slightly more complicated to get perfect but much easier once set up.
Last Edit: September 29, 2015, 08:19:55 pm by MakeCents
#using_animtree( "animtree name" );// change animtree name to the name of the atr
prior to the function that uses:
Code Snippet
Plaintext
self UseAnimTree(#animtree);
I use 4 animtrees in one gsc with this method that handles all my animations for script_models based on kvps. Slightly more complicated to get perfect but much easier once set up.
I never worked out how to get more than one working, so ended up using multiple gscs lol
always been curious as doing that twice, always gives me a error that i cant define two? lol im still new to anim stuff tbf
I haven't done anything special but the game doesn't crash now. I'm not getting errors but the anim doesn't seem to work. I have a file called cube_doors.atr with this in it:
Code Snippet
Plaintext
cube_doors_open cube_doors_close
These are the two xanims I have. I added this file to the mod.csv and this is the function in the gsc file (this is just a testing map so the function is a bit changed):
Code Snippet
Plaintext
#using_animtree( "cube_doors" );//replace nameofanimtree with the atr you have the anims in waitDoor(open,close){ // self is the door model and open/close are the triggers //for your doors, maybe set up trigger as target of model to animate //trig = getent(self.target,"targetname");//if one trig controls multiple doors, then getentarray and put the rest in another function and array thread it while(1){ open waittill("trigger",player); //other door stuff here maybe checking for cost self UseAnimTree(#animtree); self SetAnim(%cube_doors_open);//this method replace openanimname with your animname that opens the door //if you are doing those doors, you would set the model of the open door here that you will play the close door on self setmodel("cube_doors_opened");//change opendoor to open door model to play close anim on self clearanim( %cube_doors_open, 0 );//stops anim close waittill("trigger",player); //while(player istouching(trig) || trig OtherPlayersTouching()) wait(.1); //make a function to make sure no other players are touching it either called OtherPlayersTouching or whatever self SetAnim(%cube_doors_close);//this method replace closeanimname with your animname that closes the door self setmodel("cube_doors");//change back to model that you use for a closed door self clearanim( %cube_doors_close, 0 );//stops anim } }
Interesting. It all seems to be fine. I assume open and close are defined? I would add a wait(length of anim to open) in between setanims and after the second setanim to make sure it isn't just running faster than you can see.
Edit: Pretty much what blunt said.
Edit: Also the two trigger thing is bothersome, I would go with one, and also do a check for while touching for you wait in the end, like my first example. Just so the door doesn't close on the players.
Last Edit: September 29, 2015, 09:15:57 pm by MakeCents