Jump to content

Recommended Posts

I feel like this is a silly question, and I have only really skimmed the tutorials I have found on the subject but...

 

Suppose my Stategraph had a State like:

    State    {         name = "attack",        tags = {"attack", "canrotate"},        onenter = function(inst)            inst.components.lighttweener:StartTween(nil, 0, .65, .7, nil, 0, function(inst, light) if light then light:Enable(true) end end)            inst.components.lighttweener:StartTween(nil, 3.5, .9, .9, nil, .66, inst.dotweenin)            inst.AnimState:PlayAnimation("attack", true)--Meh            inst.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/charge")        end,                timeline=        {            TimeEvent(22*FRAMES, function(inst) 				--inst.components.fueled:DoDelta(-1)				if inst.on then                inst.components.combat:StartAttack()                inst.components.combat:DoAttack()				end                inst.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shoot")            end),        },                events=        {            EventHandler("animover", function(inst) inst.sg:GoToState("watch") end),        },    },

and I wanted it to have an attack animation from the back, as well as from the front, how would I let the game know which to play?

Edited by Fireandthethud

I think you need to know in which direction do target and attacker look and after that you can do the code i think.

f.e. if attacker looks forward and target looks the same direction = attack animation from the back. target looks in the direction under the angle of ~90 degrees to you = side attack. This is the algorithm, it must work if you know how to find direction of look

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...