MarcoYolo
(MarcoYolo)
September 17, 2017, 8:17am
1
So unrelated to the last question I asked…
I’ve been trying to simplify my cluttered logic brick mess by simply converting the walking functions to python scripts. I’ve encountered an issue. I’ve refrained from using the sensors in the logic bricks and instead use Game Keys(bge.events). I’ve got the motion covered but it won’t play any animations.
Code
import bge
def main():
cont = bge.logic.getCurrentController()
owner = cont.owner
keyboard = bge.logic.keyboard
mouse = bge.logic.mouse
scene = bge.logic.getCurrentScene()
armature = scene.objects[‘Player.Rig’]
#move up down, turn left right
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DOWNARROWKEY]:
owner.applyMovement((0,-.2, 0), True)
armature.playAction(“PlayerWalking”, 1, 30, 0, 2, BLEND, PLAYTYPE, LYRWGHT, IPO_FLG, SPEED, BLENDTYPE)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.RIGHTARROWKEY]:
owner.applyMovement((0, 0, .05), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTARROWKEY]:
owner.applyMovement((0, 0, -.05), True)
main()
Cotaks
(- Click for (UP)Bge resources)
September 17, 2017, 9:16am
2
armature.playAction("PlayerWalking", 1, 30, 0, 2, BLEND, PLAYTYPE, LYRWGHT, IPO_FLG, SPEED, BLENDTYPE)
After ‘2’ nothing is defined, either remove it or define the other types.
again look into console to see the errors.
Also next time could you post your code in code tags? (advanced editor # symbol) or simply use code instead of the quote text.
MarcoYolo
(MarcoYolo)
September 17, 2017, 9:20am
3
Oh, wow. Aren’t you just a problem solver? That fixed it, but the animation isn’t looping but I’ll fix it.
Cotaks
(- Click for (UP)Bge resources)
September 17, 2017, 9:53am
4
Just reading over your code, not hard to find to be honest.
Just look at the previous examples we have given you, you should be able to fix it yourself indeed
MarcoYolo
(MarcoYolo)
September 17, 2017, 10:22am
5
Well thanks to you, I learned some coding. I learned how to play animations with game keys. I also did do some research.
Also, how do you fix this annoying error?
Cotaks
(- Click for (UP)Bge resources)
September 17, 2017, 11:19am
6
just remove all spaces/tabs before that line and above/below and re tab them, should do it.
MarcoYolo
(MarcoYolo)
September 18, 2017, 8:13pm
7
Okay, I’m not as smart as I thought I would be…
So on the last script you started for me, I’m trying to add factors that would make the player walk slower. I’ve got the movement covered but what about the animations?
How do you make animations speed change?
Cotaks
(- Click for (UP)Bge resources)
September 19, 2017, 8:24am
8
i did not make a script for you Daedalus_MDW did that, i just helped you with your errors.
anyway, i am not sure if that is possible, atleast i have never used/tried it.
best is to make a new topic for it, and hope for the best.
or simply make 2 animations, one walking and 1 running.
I’m fairly sure you should just be able to change that “SPEED” variable…
MarcoYolo
(MarcoYolo)
September 19, 2017, 9:30am
10
Did that, it didn’t work for some reason…
MarcoYolo
(MarcoYolo)
September 19, 2017, 9:31am
11
Cotaks:
i did not make a script for you Daedalus_MDW did that, i just helped you with your errors.
anyway, i am not sure if that is possible, atleast i have never used/tried it.
best is to make a new topic for it, and hope for the best.
or simply make 2 animations, one walking and 1 running.
Alright, then. I’ll do so…
Also, it is possible. I have to change the SPEED variable. i’m talking about the animation speed, not the movement. I’ve got that covered.