Jump to content

Recommended Posts

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 by Berany

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.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...