1
$\begingroup$

I am using a script to decide which animation my player will run, based on if he holds a flashlight or not. All the actions can be seen in the following image. The actions's layers start from 0 and reach 7.

Image 1 - logic bricks

Here is the script I use to define which animation should play and when.

Image 2 - python

Everything works, except from the fact that when game starts and the player is still with no flashlight in his hands, he uses the "stand_f" action while he should have used the "stand_no_f". Also there is some visible lag sometimes when changing from one action to the other.

I think these problems connect to the layers somehow, since if I change "stand_no_f" action's layer to 8 instead of 0, now the correct action happens when he is still with no flashlight, but every other action stops happening or lags indefinitely.

So any ideas why the first action is wrong or why there is a random tiny lag between changes of actions?

P.S. the file is big to share and all the scripts are external that is why I did not share in the first place. Also I use a script to define sensors/conts/acts.

$\endgroup$
0
$\begingroup$

Your logic cares keyboard sensors only.

You need to describe and handle a "at startup" event. This is typically triggered via an always sensor.

enter image description here

$\endgroup$
  • $\begingroup$ If I understand correctly what you say, my always sensor with true level triggering will do this, right? It will get inside the "else" and activate the actuator with the name "stand_no_f" at the very start. Since with TLT it will always check. $\endgroup$ – Lev Oct 20 '15 at 8:02
  • $\begingroup$ No, because you enabled true level triggering it will constantly trigger the controller. You would need additional logic to "filter" the right event. - I added an image that you can see the sensor. You might want to enable [Tap] to ensure it does not evaluate positive after the first frame. $\endgroup$ – Monster Oct 20 '15 at 8:04
  • $\begingroup$ Yeah since the time I posted I changed to "states" and completely removed the python controller. The fps drop was huge cause the controller was running constantly. Thanks again. $\endgroup$ – Lev Oct 20 '15 at 8:10
  • $\begingroup$ In case of states I suggest to enable the [Level] flag to detect state entry events :D. $\endgroup$ – Monster Oct 20 '15 at 8:16
  • $\begingroup$ Yup, I did that almost 10 minutes ago, cause after using a combination of buttons for motion my animations would not work. And I experimented till I found it :) $\endgroup$ – Lev Oct 20 '15 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.