Jump to content

psychoanima

Members
  • Posts

    76
  • Joined

  • Last visited

Posts posted by psychoanima

  1. Math:CurveAngle() works perfect for my rotation need.

     

    Now I have another problem. My character is moving on X and Z axis but needs to stay locked on Z and to move only on X.

     

     

    I read in one post this method for locking:

     

    (in function Script:Start())

    vec = self.entity:GetPosition()]

     

    &

     

    ( in function Script:UpdateWorld())

    self.entity:PhysicsSetPosition(0,0,vec.z)

     

     

     

    but nothing is changing in the viewer, it's still floating on Z

  2. Honestly, I do not think that has been fully implemented as I never saw any difference in behavior from a max rotation speed between 5000 or 0.0005. What you can do is control how fast the angle value is changed to the final amount.

     

    example:

    angle = player:GetRotation(true).y --defined before main loop

    move = 0

    strafe = 0

    jump = 0

    crouch = false

    maxaccel = 1

    maxdecel = 0.5

    detailed = false

    maxrotationspeed = 0.5

    ..

    ..

    --Main Loop

    p_rot = player:GetRotation(true)

    if window:KeyHit(Key.Right) then angle = 270 end

    if window:KeyHit(Key.Left) then angle = 90 end

    finalangle = Math:CurveAngle(angle, p_rot.y, 10) --decrease step to quicken rotation

    player:SetInput(finalangle,move,strafe,jump,crouch,maxaccel,maxdecel,detailed,maxrotationspeed)

     

     

    That's really cool idea for rotation, thanks!

     

    Do you think it can be easily implemented with the script bellow:

     

    http://www.leadwerks.com/werkspace/topic/12651-2d-platformer-player-script-example/page__hl__platformer

     

    (I am using the same logic like in function Script:UpdatePhysics() )

  3. I'd also recommend using the AnimationManager lua class that Josh has provided. It's just a nice utility class to deal with animation/blending/complete callback.

     

    I am using Josh 2D platformer script example, but I have to reshape a lot of things cuz not everything is working how I wanted. I am not sure how to find AnimationManager lua class, I am rookie here, sry laugh.png

     

     

    BTW SetInput function is a time saver for sidescroller moving!

  4. I found the answer for one part of my question.

     

    I forgot to mention that for running animation I was using Time:GetCurrent() in SetAnimationFrame, that's why I get unwanted cycling animation.

     

    My code is now like this:

     

     

    
    local isrunning = 1
    
    function Script:Draw()
    
    if window:KeyDown(Key.C) then
    isrunning = isrunning +1
    self.entity:SetAnimationFrame(isrunning,1,1)
    
    end
    

     

     

    now I need to figure out how to add Idle when no key is pressed and how to blend it properly.

  5. I have 3 .fbx animation, one is for running, second is idle, third jumping. (2.5d platformer)

     

    To trigger running I am using

     

    if window:KeyDown(Key.D) then
    self.entity:SetAnimationFrame()
    end
    

     

    Problem:

    how to trigger idle animation since there is no Key release function? And how to blend it with previous animation?

     

     

    Second problem:

    I notice this when I am using KeyDown function: When I am pressing key to start the animation, releasing the key stops animation in the viewer, but animation is still looping somewhere in the background. I noticed that when I do quick press/release button on my keyboard - animation is cycling instead of starting from beginning.

×
×
  • Create New...