Need help with jump n run game

How to get this “system” to work, I have a property witch says if the fall is deadly
connected with a collision sensor, so if I touch any block with the player’s feet and the property says the fall is deadly, I die but I want to survive if i collide with this block in the right direction…
(its 3D)



thx for all replys

Well
its a piece of cake to python gurus, I guess!
With Logic Bricks…well, add a way, that when you make your character switch moving direction, to set/change a “property”, ex:
Give the character object an String property named Direction!
Then add
Keyboard Sensor - Left Arrow Key - AND - Motion Actuator - xxx
-Property Actuator - Assign - Prop : Direction - Value: “Left”
Then in the “falling” movement you can use the “Expression Controller” to filter the dead ( or not) action
Always Sensor - Expression Controler - Exp: Direction == Left - Object Actuator - End Object
Bye

Haha - That looks like N+. I’d like to see how this turns out, though. Anywho, yeah, OTO is right that you can add a direction to the object, and should he collide with a block at high speed facing the opposite direction (facing right, but collides with BlockL), then he would die. That should work alright.

EDIT: Of course, the original N (and N+) used code and math to deduce whether he would die based on speed, block orientation, etc.

Just looking at the images you posted, and assuming your ramps are polygonial objects:
you could run a script everytime your character collides with a ramp,
get the velocity of your character, and get the normal vector of your collision point with a ray sensor.
Then you could simply check with a dot product whether your character has to be killed.

THX but its 3D so there is no left and right , I just need to get a script witch says in what direction with witch speed my character is moving, but there is nothing like that, I looked at speedo scripts but cannot find any in 2.5x , so if you can find a script for the direction and speed please say it, and thx for your post …

is it possible to add a >no collision< empty or cube and get its position, after a delay of 1/60 sec it calculates: the player.pos - the empty.pos ?
so I would get the speed of each direction

There’s already properties available for getting the speed. Check localLinearVelocity and worldLinearVelocity in http://www.blender.org/documentation/blender_python_api_2_56_4/bge.types.html#bge.types.KX_GameObject

If You don’t need x, y, z just add .magnitude to get the total speed.

thx, ill try it

if i try this code:


import bge
import mathutils

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    actuator = co.actuators["state1"]
    
    if own.worldLinearVelocityz &lt; 
        
        controller.activate(actuator)
                
        own.worldOrientation
           
        
    else:
        cont.deactivate(actu)

main()

I get this error message:


Warning! user defined property name “state” is also a python attribute for object “Player”
Use ob[“state”] syntax to avoid conflict
Python error compiling script - object ‘Player’ , controller ‘Python#CONTR#47’:
if own.worldLinearVelocityz < 1
________________________.^
SyntaxError: invalid syntax

It should be own.worldLinearVelocity.z < 1 #whatever value here
Also, ‘state’ is already a property name - try changing it, and referring to it as own[‘variablename’], if you aren’t already.

EDIT: Your script is also incomplete past own.worldOrientation - nothing will happen with that particular line. It might return an error.

this script work well:confused:,but you must adding 2 empty (end rename to)
EmptyFix - Empty parent to player ,type no collision
EmptyDin - Empty no parent , type dinamic-ghost ,at this is attacched the script with always sensor true pulse mode

all in the same layer

add variable “live” to Player and set to 10
add variable “dist” to EmptyDin,set to 0

for setup change the variable M(mass)in to python,more higth,more damage,the other better no change

PYTHON:

###################
###################
###################
###################

import bge



c = bge.logic.getCurrentController()
o = c.owner
scene=bge.logic.getCurrentScene()




t=scene.objects["EmptyFix"]
m=scene.objects["EmptyDin"]

F=0.99 #### friction...this is best not change or very little
M=0.81 ####### mass....change this to setup,must be larger to 0

v=m.localLinearVelocity
dist=t.worldPosition-m.worldPosition
v=v+dist/M
m.linearVelocity[2]-=9*M
m.localLinearVelocity=v*F


###
###the damage can be relative to variable "dist"(distance)
###dist be directly proportional to impact


p=scene.objects["Player"]# assign name of obj player
dist=m.getDistanceTo(t)

if dist&gt;3:
    if dist&lt;4:
        p["live"]-=3
    if dist &gt;= 4:
        p["live"]-=11
    m.worldPosition=t.worldPosition
    #scene.addObject("Cube",o)
    


if dist&gt;m["dist"]:#control the max distance
    m["dist"]=dist


if p["live"] &lt;0:
    p.localScale=[0.2,0.2,0.2]#death




#print(dir(p))
###################
###################
###################
###################

Otherwise I think you have to use a soft body object,
empty of Sensor vertex parented to sb etc…
i dubt wich more easy way

ah…warning to jump , usually it is setup with abrupt change of speed without accelleration,that be worse of impact!

I’d try the script MarcoIT but it doesnt work for me because I have lots of sensors on my Player,
I have made a video what happens if I use the script and without it :

yes, I’ve seen;)
The other day I forgot to tell you something important
Set The blender like this:
Set 3D windows to wireframe (semi transparent)
in property windows, go to scenes, and enable visualization physic
and “live” to 1000
in this mode you can see the empty, and how the scripts work
if set M at 0.5 or 0.8 (probably hight) you see better how work

other … the cube if activated must be “no-collision”(otherwise block the player)

for many sensor, is no problem, the scripts work in different paths, if sensors if active or not, make no difference, the script get only information from Emptifix movement,EmptyDin move to Efix filtered from script

try that :wink:

I tryd it but it activates the sensors i think and it scales my player : when i start the game engine (p button) it scales my player so he is smaller and the sensors, whitch are parentet to him too but the colision box has the same size so the sensor at the bottom dont toches the ground what can I do ??
(playerlive is constant at -1 if i set it at the start to 10)
thx for your reply

Just looked at the first post. You might want to check this thread:

Collision

I used such algorithm to determine if a projectile has to explode or not dependent on the impact. I think it is what you need.

if i understand it ist the right thing for me, thx monster that looks good and will help me in other games too