metall87 Posted April 10, 2014 Share Posted April 10, 2014 Hi guys, I hope I've put this in the right place. I've searched all over the web on this topic, but no luck. Ok, here's my problem,I'm making a mod involving the player and another npc in a scene with custom animations, basically the two actors get close to each other, perform the animation (hug and kiss) and then they split up (something similar to ssl framework, but much more simple and... without sex of course :laugh: ). That's ok, but the problem is that when this two actors perform the animation, one of them falls to the floor; more specifically, the function Debug.ToggleCollisions() doesn't seem to work properly. I tried to set the Z position of the npc, but -even with ToggleCollisions called- no success.I tried to put a Collision box under the npc to even the two of them, didn't work. To be more specific in this matter, if I try to raise the npc, say, 30 units from the floor, it works, the npc stays in the air (obviously the animation looks weird, a actor in the floor, and the other mid air, both trying to hug each other :tongue: ). but if I try to raise the actor only 5 units from the floor, it falls, as if the ground were attracting the npc down. Ok, here's the function that I'm working on, this is called by the scene. Reveal hidden contents ;============================================ Function BeginPreparationsForAnim() actor pPlayer = Alias_Player.GetActorRef()actor pTarget = Alias_Target.GetActorRef() Pval = pPlayer.GetScale()Tval = pTarget.GetScale() pPlayer.SetScale(1.0)pTarget.SetScale(1.0) Debug.ToggleCollisions() Game.DisablePlayerControls(true, true, true, false, false, true, true) Game.ForceThirdPerson()Game.SetPlayerAIDriven() ;pPlayer.SetRestrained(true);pPlayer.SetDontMove(true)pTarget.SetRestrained(true)pTarget.SetDontMove(true) Debug.SendAnimationEvent(pTarget, "Arrok_StandingForeplay_A1_S1")Debug.SendAnimationEvent(pPlayer, "Arrok_StandingForeplay_A2_S1") pTarget.MoveTo(pPlayer, 100.0 * Math.Sin(pPlayer.GetAngleZ()), 100.0 * Math.Cos(pPlayer.GetAngleZ()), pPlayer.GetHeight() - 120.0) ;TPosX = pTarget.GetpositionX() <<<;TPosY = pTarget.GetpositionY() <<< This was just a test;TPosZ = pTarget.GetpositionZ() <<<;pTarget.SetPosition(TposX, TPosY, TposZ +5) <<< EndFunction ;========================================= After 20 secs, another function is called to return the actors to normal state and regain their current Scale values. Here's a sample pic. Reveal hidden contents http://i58.tinypic.com/mlo47a.jpg For those who want to know, the animation is Arrok Standing Foreplay, part of Sexlab Framework animations. If anyone can help me, or point me in the right direction, It will be much appreciated :yes: , so I can stop hitting the wall with this. :wallbash: Thanks in advance. Metall Link to comment Share on other sites More sharing options...
fore Posted April 10, 2014 Share Posted April 10, 2014 With the newly supported paired animation in FNIS you can have it the right way. Other ways to force characters into a place are furniture animations, or setvehicle() Link to comment Share on other sites More sharing options...
metall87 Posted April 11, 2014 Author Share Posted April 11, 2014 Oh, thank you Fore :thumbsup: , I will look into that. Link to comment Share on other sites More sharing options...
metall87 Posted April 15, 2014 Author Share Posted April 15, 2014 (edited) Ok, I've manage to do it! I'd like to post my code here, so anyone who wants to work with animations in the future may have an idea, or at least a reference with this, because there's so little information about this topic (Or at least, I haven't found it). Please notice that I'm not a Papyrus expert programmer or anything like it. The code might not be elegant, but does the job perfectly. What I've accomplished here was by reading the FNIS document for modders (Thanks Fore, that doc helped me a lot :thumbsup: to understand the basics), by pure deduction and by trial and error.the primary function of the code below is to play a scene with custom animation events already recorded within the 0_master.HKX file (FNIS Animations). An event which normally does not work if you call the PlayIdle () function. Eg: ssl animations, Shake it, Fnis, etc. I'll take the player and Mjoll as examples in this scene, probably you'll modify that. Reveal hidden contents ;================================================= Scriptname aaTestAnimsQuestScript extends Quest Conditional ReferenceAlias Property Alias_Mjoll Auto ReferenceAlias Property Alias_Player Auto ;I'm running this with Ref aliases for another purpose, but you can do it with Actor references without problems. Static Property StaticBaseRef Auto ;Static base to mark the spots for the anims, this is mandatory for the SetVehicle() to work properly. ;If you use an actorbase, you will have misplaced animations. (At least for me, this was the case...) ActorBase Property StagerBaseRef Auto ;The StagerBase is basically a mudcrab, any actorbase should work, but only creatures ;NPC have another physics that doesn't work well when you use PlaceAtMe() or MoveTo() with irregular floors. Faction Property HugAndKissFaction Auto ;Faction that already use the mudcrab, so you will not be attacked by it. Actor MStagerRef Actor FStagerRef ;actor variables that records the Placed Bases for both characters involved in the animation. ObjectReference MStaticBaseRef ObjectReference FStaticBaseRef ;Object variables that records the Placed Bases for both characters involved in the animation. float Pval float Mval ;Variables that saves the characters height and then restore them. ;============================================ Function BeginPreparationsForAnim() actor pPlayer = Alias_Player.GetActorRef() actor pMjoll = Alias_Mjoll.GetActorRef() Pval = pPlayer.GetScale() Mval = pMjoll.GetScale() pPlayer.SetScale(1.0) pMjoll.SetScale(1.0) pMjoll.SetDontMove(true) pMjoll.SetRestrained(true) pPlayer.AddToFaction(HugAndKissFaction) pMjoll.AddToFaction(HugAndKissFaction) Debug.ToggleCollisions() Debug.ToggleMenus() Game.DisablePlayerControls(true, true, true, false, false, true, true) Game.ForceThirdPerson() Game.SetPlayerAIDriven() MStagerRef = pPlayer.PlaceAtMe(StagerBaseRef) as Actor FStagerRef = pMjoll.PlaceAtMe(StagerBaseRef) as Actor FStagerRef.MoveTo(pPlayer, 101.0 * Math.Sin(pPlayer.GetAngleZ()), 101.0 * Math.Cos(pPlayer.GetAngleZ()), pPlayer.GetHeight() - 125.0) MStagerRef.MoveTo(pPlayer) MStaticBaseRef = MStagerRef.PlaceAtMe(StaticBaseRef) as ObjectReference FStaticBaseRef = FStagerRef.PlaceAtMe(StaticBaseRef) as ObjectReference pPlayer.SetVehicle(MStaticBaseRef) pMjoll.SetVehicle(FStaticBaseRef) Debug.SendAnimationEvent(pPlayer, "Arrok_StandingForeplay_A2_S1") Debug.SendAnimationEvent(pMjoll, "Arrok_StandingForeplay_A1_S1") MStagerRef.Disable() FStagerRef.Disable() MStagerRef.Delete() FStagerRef.Delete() RegisterForSingleUpdate(30.0) EndFunction ;========================================= ;Ok, basically, what I'm doing here is declaring the actors in another variable for easy use, then saving and balancing the actors height ;shutting down collisions and menus, and immobilize both actors ;then I place 2 mudcrabs for each character, move them to the desire location. ;(if you're wondering why I have used placeatme() and then moveto() at player with the same mudcrab, That's not redundant code ;that's because those fu...ing mudcrabs appear 100 units away from you when you call PlaceAtme, in fact, all the creatures did the same :/ ) ;the mudcrabs marks the location where you want to place the static bases. ;Then call on both characters the SetVehicle() function on the bases. ;play the desire anim event. ;remove the mudcrabs so I can avoid bloating saves. ;and register a single update to give the anim some time to play it. ;when the time ends, the event OnUpdate() runs. wich basically, what it does, it's clean all the mess above this :P. ;========================================= Event OnUpdate() actor pPlayer = Alias_Player.GetActorRef() actor pMjoll = Alias_Mjoll.GetActorRef() pPlayer.SetVehicle(None) pMjoll.SetVehicle(None) Debug.SendAnimationEvent(pPlayer, "IdleForceDefaultState") Debug.SendAnimationEvent(pMjoll, "IdleForceDefaultState") MStaticBaseRef.Disable() FStaticBaseRef.Disable() MStaticBaseRef.Delete() FStaticBaseRef.Delete() pPlayer.SetScale(Pval) pMjoll.SetScale(MVal) Game.SetPlayerAIDriven(false) Game.EnablePlayerControls() Debug.ToggleCollisions() Debug.ToggleMenus() pPlayer.RemoveFromFaction(HugAndKissFaction) pMjoll.RemoveFromFaction(HugAndKissFaction) pMjoll.SetDontMove(false) pMjoll.SetRestrained(false) pMjoll.EvaluatePackage() EndEvent ;================================================= Well, I hope that this serves well to anyone who wants to do the same thing that I did. :thumbsup: Best Regards Metall Edited April 15, 2014 by metall87 Link to comment Share on other sites More sharing options...
Recommended Posts