I'm making a project in BGE where I need to implement speed variations in an object with single press and long press of a key? (speed increase with long press) please help its urgent

  • 1
    $\begingroup$ Typically a force would do exactly that. As longer you apply the force as bigger the velocity. But I do not know if that is what you want. $\endgroup$
    – Monster
    Dec 19 '16 at 8:12

add a keyboard sensor and connect it to a python controller

    own = cont.owner
    key_w = own.sensors['w']# can assign any key make sure the sensor is the same

        max_speed = 2
        if key_w.positive:
            if speed_var < max_speed:
              speed_var += 0.25#how quickly to accelerate  
        speed_var = 0#you can also do the same here by subtracting 0.25
# until 0 is reached...make sure you do a check that it stays above 0

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.