Berany Posted January 31, 2020 Share Posted January 31, 2020 (edited) Hi. I'm making a custom character mod. This character has followers who fight together when the player is attack enemy or attacked by the enemy. I know how to get creatures to attack the enemy directly. But what I want is for the creatures to spawn my custom prefab to the enemy's position. For example, when a player meets an enemy, this follower summons lightning(Example of my custom prefab) at the enemy's position. Can you tell me how to do this? I'd be very grateful if I could get some help because I know only basic things about Lua. I'm sorry if my english was so immature that it was hard for you to understand. Thank you for reading it. Edited January 31, 2020 by Berany Link to comment https://forums.kleientertainment.com/forums/topic/115386-helphow-to-spawn-prefab-when-the-creature-attacks/ Share on other sites More sharing options...
Yakuzashi Posted January 31, 2020 Share Posted January 31, 2020 Hi. I don't know if you wanted to achieve exactly this effect, but there it is. Inside of your follower's stategraph you need to find state "attack" Quote State{ name = "attack", tags = {"attack", "notalking", "abouttoattack", "busy"}, something like this. Then in "events"... Quote events = { EventHandler("animover", function(inst) if inst.AnimState:AnimDone() then inst.sg:GoToState("idle") local x, y, z = inst.Transform:GetWorldPosition() SpawnPrefab("lightning").Transform:SetPosition(x, y, z) inst:Remove() end end), }, ...it should look like this. If it didn't help I will try something else. 1 Link to comment https://forums.kleientertainment.com/forums/topic/115386-helphow-to-spawn-prefab-when-the-creature-attacks/#findComment-1303279 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