Hi Everybody,
Is it possible to modify the physic “radius” of an objet with a python script ?
I don’t find it in http://www.blender.org/documentation/blender_python_api_2_65_9/bge.types.html#bge.types.KX_GameObject
If it’s not possible, how to crouch a character without moving its origin ?
Thanks,
Greg
with replaceMesh you can replace the collision mesh of an object, replace when crouched, and revert when standing up. alternatively you could scale.
Use a seperate collision object, and then change the scales, with something like:
radius = 5
col_obj.worldScale = [radius, radius, radius]
graphics_obj.worldScale = [1,1,1]
Ok, thank you, i’ll try
Thank you, it’s functionning, but when i do that, the physic seems to freeze : the character is flying, and when i press a keyboard key, it’s falling on the ground… do you know why ?
And sometimes, i fall under the floor…
Edit: ok, it functions very well with:
if own["crouching"]:
scene.objects["Player"].position.z -= 0.1
scene.objects["Player"].worldScale = [4,1.1,0.4]
own.worldScale = [1,1,1]
else:
scene.objects["Player"].position.z += 1
scene.objects["Player"].worldScale = [1,1,1]
own.worldScale = [1,1,1]
own is the armature
Player is the collision mesh