Once again stuck with python

Hello,

I need an object to apply a given linearVelocity depending on some other influences…

Therefore, I have this little script:

    
unhookedJump = (abs(edging * boardspeed)/2)    
    own['unhookedJump'] = unhookedJump
    
    if air.positive and unhooked.positive and space.positive:
        own.setLinearVelocity[(0.0,0.0,unhookedJump),0)]

edging and boardspeed are integer values that change dynamically.
So what I need, is to apply the value that results out of edging and boardspeed one time as linear velocity with the small “add” button activated.

And I have no idea how to do that…

And that is the error message that I get:

Python error compiling script - object ‘twintip-physik’, controller ‘And.010’: File “Pop.py”, line 17
own.setLinearVelocity[(0.0,0.0,unhookedJump),0)]
^
SyntaxError: invalid syntax

Blender Game Engine Started
Blender Game Engine Finished

Basically, what I want to achieve is as if I had an actuator wich has some Z linear Velocity ran one time with the add-button activated. (Before I had it this way: value 10 at linearVelocity with add), which gave me a nice jump. But I need the jumpheight to change depending on the velocity and angle of the object)

Hope someone can help me out.

Thanks in advance!

you got your brackets and parenthesis reversed

own.setLinearVelocity[(0.0,0.0,unhookedJump),0)] should be

own.setLinearVelocity([0.0,0.0,unhookedJump],0)

im not sure but your unhooked variable shouldnt be parenthesis either, may keep it from working

unhookedJump = (abs(edging * boardspeed)/2) should be
unhookedJump = abs(edging * boardspeed)/2
or
unhookedJump = abs(edging * boardspeed/2)
or
unhookedJump = abs((edging * boardspeed)/2)

Thanks a lot for your help, it solved the problem!

But not the code shows up a new issue…

All the movement is stopped and only the linearVelocity Z is applied.
I guess it is because the other values are set to 0.0

Is there a way to solve this?

Nevermind, I fixed it :slight_smile:

Here’s the code, if someone someday has the same problem:

unhookedJump = abs((edging*boardspeed)/4)
if unhookedJump >= 15:
    unhookedJump = 15
    
jumpX = own.localLinearVelocity.x
jumpY = own.localLinearVelocity.y
    
own['unhookedJump'] = unhookedJump
    
if air.positive and unhooked.positive and space.positive:
    own.setLinearVelocity([jumpX,jumpY,unhookedJump],0)

You do not need setlinearVelocity

You can just use

own.worldLinearVelocity =Vector