0
$\begingroup$

This might be a very simple problem but my knowledge on programming is limited to logic bricks. I ironically have a player script which determines the speed of my character and was wondering how I can have this change once a certain number is reached on my integer game property (i.e. when "counter" is equal to 5, speed becomes higher) ["Move: 2" refers to speed]. Here is the relevant section of the script.

import bge

from bge import render

cont = bge.logic.getCurrentController()

own = cont.owner

scene = bge.logic.getCurrentScene()

empty = scene.objects["Empty"]

pointer = scene.objects["Empty.002"]

empty.worldPosition = own.worldPosition

move = 2

emptyrot = cont.actuators["rotz"]

playerRot = cont.actuators["playerRot"]

mouseMove = cont.sensors["MouseLook"]

keyboard = bge.logic.keyboard.events

W = keyboard[bge.events.WKEY]

A = keyboard[bge.events.AKEY]

D = keyboard[bge.events.DKEY]

I am assuming this requires an "if" statement but how would I write this? Thanks.

$\endgroup$
3
  • $\begingroup$ please provide blend file. and looks like your script isn't complete... $\endgroup$
    – Chris
    Commented Jan 5, 2022 at 6:35
  • $\begingroup$ what do you mean by edit speed? speed was changed here: blender.stackexchange.com/questions/248042/… $\endgroup$
    – Chris
    Commented Jan 5, 2022 at 6:36
  • $\begingroup$ Here is the example file. As you collide with the blue spheres it adds to the counter property. Which edits to the script would you suggest to boost speed (e.g. change the speed value from 1 to 5) once the counter is equal to 3? thanks. <img src="https://blend-exchange.com/embedImage.png?bid=EmO0XGen" /> $\endgroup$
    – Minato
    Commented Jan 5, 2022 at 14:41

1 Answer 1

1
$\begingroup$

I think I made something that you're looking for. A dynamic speed operation that is activated on collision with a speed boost perk. The speed boost is deactivated after a certain stated time has elapsed, thus returning the player speed to its default speed.

In my blend you can walk around with W, A, S, D keys, look around with the mouse. And also collide with the blue-sphere boost perk for speed. The player speed should also increase accordingly after collision and decrease after a certain time.

Blend

https://github.com/RandomPandaStudios/BSE-Blend-Storage/blob/main/example_mine.blend

$\endgroup$
2
  • 1
    $\begingroup$ Looks good, thanks for the help. $\endgroup$
    – Minato
    Commented Jan 5, 2022 at 20:47
  • $\begingroup$ Glad I could help. $\endgroup$
    – RPaladin
    Commented Jan 6, 2022 at 2:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .