Wonderlarr Posted December 26, 2021 Share Posted December 26, 2021 I've got a pretty simple script, where I spawn a prefab, move it to where it needs to be, and then set it's light override. local c = SpawnPrefab("superjump_fx") c.Transform:SetPosition(inst.Transform:GetWorldPosition()) c.AnimState:SetLightOverride(1) However, although the Transform is able to be accessed without a problem, the AnimState returns as nil whenever I try to do anything with it, even outside of SetLightOverride, why is this happening? I'd love to know as this just doesn't make sense to me, the AnimState should be accessible by everything since it's a public variable, made inside the entity's constructor, so it always exists. Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/ Share on other sites More sharing options...
Leonidas IV Posted December 29, 2021 Share Posted December 29, 2021 Does this prefab have AnimState? The code below must be in this prefab: inst.entity:AddAnimState() Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1529205 Share on other sites More sharing options...
Wonderlarr Posted December 30, 2021 Author Share Posted December 30, 2021 On 12/29/2021 at 9:15 AM, Leonidas IV said: Does this prefab have AnimState? The code below must be in this prefab: inst.entity:AddAnimState() It definitely does, it's an FX prefab I made which really only serves the purpose of animating. It works correctly on it's own but I can't manipulate it outside of its own prefab file. Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1529531 Share on other sites More sharing options...
Leonidas IV Posted January 1, 2022 Share Posted January 1, 2022 On 12/30/2021 at 6:53 PM, TheSkylarr said: It definitely does, it's an FX prefab I made which really only serves the purpose of animating. It works correctly on it's own but I can't manipulate it outside of its own prefab file. Hmm, maybe there might be a problem importing the prefab by SpawnPrefab. Maybe the prefab is not being registered correctly? Or is the return in the prefab file incorrect? Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1529969 Share on other sites More sharing options...
Wonderlarr Posted January 1, 2022 Author Share Posted January 1, 2022 5 hours ago, Leonidas IV said: Hmm, maybe there might be a problem importing the prefab by SpawnPrefab. Maybe the prefab is not being registered correctly? Or is the return in the prefab file incorrect? This seems to happen with any prefab I spawn this way, it's very strange, I used researchlab as an example and it just doesn't work. Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1530048 Share on other sites More sharing options...
penguin0616 Posted January 2, 2022 Share Posted January 2, 2022 (edited) I don't have any issues accessing AnimState. Not enough details to know what's going on in your case though. If I had to guess, you're probably doing something weird in the prefab or you've somehow tampered with the spawning. Edited January 2, 2022 by penguin0616 1 Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1530074 Share on other sites More sharing options...
Wonderlarr Posted January 2, 2022 Author Share Posted January 2, 2022 20 hours ago, penguin0616 said: I don't have any issues accessing AnimState. Not enough details to know what's going on in your case though. If I had to guess, you're probably doing something weird in the prefab or you've somehow tampered with the spawning. Actually I think I may have the answer, since I was trying to spawn an FX prefab, AnimState didn't exist ON THE SERVER ONLY, it was only being added if the prefab was spawned on a client. Didn't consider it but I just needed to add an if not TheWorld.ismastersim before changing the AnimState. Link to comment https://forums.kleientertainment.com/forums/topic/136513-cant-access-a-prefab-animstate/#findComment-1530209 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now