Hey guys,
Not sure if anyone can help me out. I have a weird issue right now where the running animation for the character I am using does not play when I am running to the right. However the idle animation seems to run no matter which direction I am facing.
Script.movespeed = 5 --float
Script.cameradistance = 40 --float
Script.camerazoom = 8 --float
Script.orthographicseffect = 1 --float "Flatness"
Script.camerarange = 10 --float
Script.jump = 15 --int
Script.ismoving = false --bool
Script.isjumping = false --bool
--Animation variables
Script.animationspeed = 1.0 --float
Script.idlesequence = 0 --int
Script.runsequence = 0 --int
Script.jumpsequence = 0 --int
function Script:Start()
self.playerangle = -90.0
self.camera = Camera:Create()
self.entity:SetPhysicsMode(Entity.CharacterPhysics)
self.camera:SetRotation(0,0,0)
self.camera:SetZoom(self.camerazoom*self.orthographicseffect)
self.camera:SetRange(self.cameradistance*self.orthographicseffect-self.camerarange, self.cameradistance*self.orthographicseffect+self.camerarange)
if self.entity:GetMass() == 0 then self.entity:SetMass(10) end
end
function Script:UpdateWorld()
--Update the camera
self.camera:SetPosition(self.entity:GetPosition())
self.camera:Move(0,1.8/2,-self.cameradistance*self.orthographicseffect)
end
function Script:UpdatePhysics()
local window = Window:GetCurrent()
local move = 0
local jump = 0
--Set the players direction if they move left or right
if window:KeyDown(Key.D) then
self.playerangle = -90.0
self.ismoving = true
move = move - self.movespeed
else
self.ismoving = false
end
if window:KeyDown(Key.A) then
self.playerangle = 90.0
self.ismoving = true
move = move - self.movespeed
else
self.ismoving = false
end
--Set the players jump if space is hit
if window:KeyHit(Key.Space) then
jump = self.jump
end
self.entity:SetInput(self.playerangle,move,0,jump,false,1.0,1.0,true)
end
function Script:Draw()
local t = Time:GetCurrent()
if self.ismoving == true then
self.entity:SetAnimationFrame(t/100.0*self.animationspeed,1,self.runsequence)
elseif self.ismoving == false then
self.entity:SetAnimationFrame(t/100.0*self.animationspeed,1,self.idlesequence)
end
end