In state 1 I have 2 always connected to python controller
the first of the python controller has a script that moves the character
the next always has a script that when detects the ground and the space key changes to state 2
In state 2 I have a delay that activates the jump, then always that is connected to a python controller to move in a different way in the air and finally an always connected to a python controller to detect the ground and return to state 1
The problem is that when I’m in state 1 and I jump, that is I press space key (change to state 2) then I go back to 1 and when I want to jump again, it changes to state 2 (that is good) but the code that moves the characther in a different way is not executed
that is the jump and movement only works once
Game.blend1 (540.3 KB)
Vortex101
(Vortex101)
February 1, 2024, 7:36pm
2
In STATE2 swap “Move2” script to “Move” script and it runs fine.
Thank you but I want in state 2 to keep the script move2
If you look at the script, move2 has a different way to move (only one direction every jump)
musikai
(musikai)
February 2, 2024, 7:32pm
4
In all (!!) your scripts (also the ray scripts) remove the brackets from the function calls:
instead of
W()
or if W()...
use
W
or if W...
EDIT: no, this idea was complete nonsense
thanks you but I don’t understand
something like that
(move2)
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
print(“hey”)
keyboard = bge.logic.keyboard
w_key = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.WKEY]
s_key = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SKEY]
a_key = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.AKEY]
d_key = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DKEY]
velocidad = 0.32
def W():
own.applyMovement((0, velocidad, 0))
def S():
own.applyMovement((0, -velocidad, 0))
def A():
own.applyMovement((-velocidad, 0, 0))
def D():
own.applyMovement((velocidad, 0, 0))
if not “key” in own:
own[“key”] = “”
Logic for W
if w_key and (own[“key”] == “” or own[“key”] == “w”):
own[“key”] = “w”
W
print(“work W”)
Logic for S
elif s_key and (own[“key”] == “” or own[“key”] == “s”):
own[“key”] = “s”
S
print(“work S”)
Logic for A
elif a_key and (own[“key”] == “” or own[“key”] == “a”):
own[“key”] = “a”
A
print(“work A”)
Logic for D
elif d_key and (own[“key”] == “” or own[“key”] == “d”):
own[“key”] = “d”
D
print(“work D”)
Game2.blend (540.5 KB)
musikai
(musikai)
February 2, 2024, 11:06pm
6
sorry, I was totally wrong. Brackets like in your first post are correct.
Just remove the space in ray2 script:
change
if ray():
own["key"] = " "
cont.owner.state = 1
to
if ray():
own["key"] = ""
cont.owner.state = 1
Game.blend (540.3 KB)
1 Like