Jumping ball, bad timing

Posted By: theDust

Jumping ball, bad timing - 02/27/09 13:13

Hello again. My goal is a ball that should always jump in the same way. At my testlevel the ball is only jumping, no other movement, so its easier to see the problem. When the ball is jumping continuously you see that sometimes the ball is jumping right in the moment when he has touched the ground. But sometimes he sticks to the ground a few millisecs and makes a jump half of the height as the jump before.

Here the whole project (keep pressing space to jump, maybe wait a little bit at the beginning until the ball doesn't rotate any more):
http://www.file-upload.net/download-1487600/testjump.rar.html
Here the code:
Code:
#include <acknex.h>
#include <default.c>

ENTITY* pointer;
VECTOR jump;

function main() 
{
   video_screen = 2;
   video_mode = 8;	
   mouse_mode = 1;	
   fps_max = 60;  
   wait(-1);
   ph_fps_max_lock = 120;	
   level_load ("level1.wmb"); 
   ph_setgravity (vector(0, 0, -700));   
} 


function coll() {
	
   jump.x = 0; jump.y = 0; jump.z = 500;  
	
   if(key_space )
   {     
      phent_addvelcentral(pointer,jump);
   }
    
}

action playerj() 
{
  pointer = my;
  my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); 
  my.event = coll;
  phent_settype (pointer, PH_RIGID, PH_SPHERE); 
  phent_setmass (pointer, 1, PH_SPHERE);
  phent_setfriction (pointer, 500); 
  phent_setdamping (pointer, 50, 50); 
  phent_setelasticity (pointer, 0, 0);
}


When I raise the ph_fps_max_lock it gets a bit better, but the problem remains. So, help would be great.
Posted By: Blade280891

Re: Jumping ball, bad timing - 02/27/09 18:40

Random guess; is that because it is using physics ?
Posted By: theDust

Re: Jumping ball, bad timing - 02/27/09 19:01

Most probably yes. Or something with the collisionsystem. Or something inbetween.
Posted By: theDust

Re: Jumping ball, bad timing - 03/01/09 12:51

After intense research, no answers and hours of experimenting, I can assume that the physics from gamestudio are not able to let a object jump properly(!).

Or maybe: Im not able to let a object jump properly. So please, let's fill this ridiculous knowledge gap wink

PS: And no, I can't try to use newton, because I can't update my A7-version, because I can't download the update, because someone has ruined my adsl and downloading 1 mb needs 2 hours (and costs 2 €)
Posted By: Spirit

Re: Jumping ball, bad timing - 03/01/09 16:34

I think, the problem is what youre doing here:

function coll() {

jump.x = 0; jump.y = 0; jump.z = 500;

if(key_space )
{
phent_addvelcentral(pointer,jump);
}

}

I think this is an odd mix of physics and script. Youre using an event and adding your own velocity by code, why? I think jumping should better be controlled by physics, elasticity and so on. Have you tried it with physics?

Posted By: theDust

Re: Jumping ball, bad timing - 03/01/09 17:44

But when space is pressed I want to add a force additional to the elasticity of the object. In the test the elasticity is set to null, cause you can better see the irregular jumps. Hmmm, maybe I should simply raise the elasticity when space is pressed.
Thx for the mental input smile
Posted By: jcl

Re: Jumping ball, bad timing - 03/02/09 07:07

When you want to apply external force by pressing a key, phent_addvelcentral is correct. But it's not correct for "adjusting" the elasticity of physics objects. Mixing physics and non-physics won't work.

There's a workshop and a simple demo for kicking a ball.


© 2024 lite-C Forums