|
| 09 Apr 2015 10:56 AM |
Hey, I've followed the wiki about playing an animation on an NPC but now I'm a bit stuck... I don't know how to stop the animation the way I want it to stop?
So basically I have this in a touch-event.
local animation = hit.Parent.LehAnimation local animController = hit.Parent.LehAnimationController _G.animTrack = animController:LoadAnimation(animation) hit.Parent.Torso.Anchored = true _G.animTrack:Play()
So as you can see there, I'm currently using a global variable but I don't want to use global variables because I want this to work with a lot of animTracks of the same kind. You can also see that there's a Animation and a AnimationController located inside the NPC.
Now, I have it so the the NPC can pathfind by the player so if the player were to use Pathfinding on the NPC, I would like to stop the animation.
I've done:
if _G.animTrack ~= nil then _G.animTrack:Stop() _G.animTrack = nil end
Inside the pathfind and this works okay but as I said I want to run multiple animations (Could be over 200 or so in the future >.<)
Has anyone got any ideas? Thanks. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 10:59 AM |
Also, for some reason I can't move the torso of the NPC or rotate it, when I'm working on animation? Why is this and is there a solution?
Thanks again. |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Apr 2015 11:00 AM |
em, y _G?
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 11:01 AM |
| The pathfinding script is located inside a different script, that's why I can't access "animTrack", so I had to use a global variable in order to access it. I'm trying not to use a _G variable though. |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Apr 2015 11:04 AM |
hmmm... well I dunno wat the Hierarchy looks like in ur Game, and if u did tell it would take some time to check everything and stuff :/ if it was my Game I could Fix it in a few Secs prob XD sry, I can't help :\
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 11:09 AM |
I think I've found a solution... I've got it so if you leave the area then a TouchEnded stops the animation without having to go in another script ;o ;3 Hopefully TouchEnded doesn't glitch out tho xD
I've got another problem on my hands though... I can't move the character's torso and I can't rotate it either ;S I think this is because the HumanoidRootPart is the same size as the Torso so I'm locking in on the HumanoidRootPart instead of the torso ;/ Is there a way to make the Torso appear in front of the HumanoidRootPart so I can edit it or no? I can't move the HumanoidRootPart or my NPC disappears when I start the game xD |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Apr 2015 11:20 AM |
em all u could do rlly is change the 'Root Hip' C1 :/
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 11:30 AM |
| Ah okay, thanks! :D Done. I might have to bump this later because I'm not sure if the TouchEnded will work so well but for now everything's good, thanks ;3 |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 11:35 AM |
| O, It seems that I have to have the motor6D already in there while animating or when I use the HumanoidRootPart, nothing is connected to it so I can't animate with it, I can use the Torso but then I have the same problem as before as I can't move the main part or HumanoidRootPart still with it ;S |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Apr 2015 12:47 PM |
| Oh god and the animation isn't viable too, it works for one NPC but if another NPC touches it then It doesn't work because the first animTrack gets overridden by the second one so the first npc never stops the animation D: |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Apr 2015 01:41 PM |
np... and em... well, wats exactly the Problem? I can't understand...
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 03:40 PM |
Ah, well basically I have a Part you can touch and when the npc touches the Part, the npc plays an animation. If NPC1 were to touch the part, it would set this up:
local animation = hit.Parent.LehAnimation local animController = hit.Parent.LehController animTrack = animController:LoadAnimation(animation)
and then play the animation with animTrack:Play()
The problem with this though is that if the second NPC were to touch the Part, it would over-ride the animTrack so the TouchEnded event I have where it stops the animation with :Stop() wouldn't stop the first NPC
These animations loop btw ^^ |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 03:52 PM |
Ah, well basically I have a Part you can touch and when the npc touches the Part, the npc plays an animation. If NPC1 were to touch the part, it would set this up:
local animation = hit.Parent.LehAnimation local animController = hit.Parent.LehController animTrack = animController:LoadAnimation(animation)
and then play the animation with animTrack:Play()
The problem with this though is that if the second NPC were to touch the Part, it would over-ride the animTrack so the TouchEnded event I have where it stops the animation with :Stop() wouldn't stop the first NPC
These animations loop btw ^^ |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Apr 2015 04:40 PM |
oh i dunno, might be cos Roblox "might" not record TouchEnded if it wasnt't the Part that moved, but something moved it... try maybe changing, from the Part.TouchEnded to NPC's BodyPart.TouchEnded and check if it's the same Part that u want to make the Effect... if u get me |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 06:43 PM |
| I don't think that'll work either because I can't transfer animTrack = animController:LoadAnimation(animation) anywhere;/ Sure I could transfer that to the NPC but the .Touched might be different than the .TouchEnded Part if you know what I mean. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 06:58 PM |
| I don't think we was talking about the same thing actually nvm but basically I don't think I can use a TouchEnded because if one NPC were to touch a part it would animTrack:Play() and then if another one touches the part it would also animTrack:Play() but it would over-ride the first NPC that touched it so animTrack would belong to the second NPC and not the first so if the first one were to TouchEnded the part, the animation would still continue. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 07:24 PM |
Okay, there's 3 very important steps you need to follow to make this work:
1) lOOK at your post. 2) lOOK at the sp00ky "the the". 3) Use grammar correctly. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2015 07:31 PM |
| ehh? You can clearly see that's a typo... ;/ |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 10 Apr 2015 07:43 AM |
lol I didn't know wat I said XD so... u could've used Debounce, which could Record wen 1 Dude Touches it, then Debounce is true so wen some other dude Touches it it doesn't Record it... well ya get wat I mean XD |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 07:53 AM |
I got 2 steps for you king.
1. Put this in another thread, it's not longer "How to stop an animation" 2. Use a freaking ModuleScript, _G sucks. |
|
|
| Report Abuse |
|
|