Blackvoxel > Programming with Blackvoxel

Programmatic handling of the player

(1/1)

Yves:
I was pondering the creation of a program to move the player faster, more specifically an elevator, because going down/up stairs is so slow!

I had the feeling that the answer was in PlayerAddAccel or PlayerSetAccel. But playing with one only made the game more/less smooth, and playing with the other either 1º moved me of a few pixels, or 2º moved me a dozen voxels in the air, and then I died falling.

I was not able to understand either of these functions by trial-and-error… Is there a better explanation of these functions somewhere?

MUY_Belgium:
I have not used those function too.  Indeed throwing the user anywhere to the sky rapidly kill it.  There is programmation exemples but i cannot remember where i found then.  I noticed that this code cause the player to go up really fast.  I usually finish this with "u" (stop all robots).  Use this onderground only!

Voxel_Step()
{
  local Diff = GetInfo(5) - GetY(); 
  if (GetZ() == GetInfo(6)) //  && Diff>0 && Diff<4)
  {
    PlayerSetAccel(0.0, 1500.0, 0.0)
    if (Diff>1) Move(4);
  }
}

For horizontal displacments, I could not manage to use PlayerSetAccel and used PlayerMove instead.  I really cannot figure out what the numbers figures, player displacement seems not proportionnal to the numbers given in arguments but

PlayerMove(15.0, 0.0, 0.0);

seems to safelly displace the player by 23 voxels if the place is empty with a ground.

You may want to foound a way to limit the number of UP to 16, 32 or 64 voxel depending upon the extraction robot you are using...

Enigma:
Hi MUY_Belgium,

Thanks for your suggestions.

About PlayerSetAccell(), the player displacement is not proportionnal to the values because of air friction and ground friction. Blackvoxel use realistic physics formulae. To make it simple, the air friction is proportionnal to square of the speed. So, if you accelerate the player to an high speed, the friction will be very high... so the speed will go down very fast.
In an realistic world, the player should die above some limits.

For PlayerMove(), there is a bug. The good news is that's already fixed in our work. Stay tunned, we'll try to make a bugfix release in the next few days.

The values indicated in PlayerMove() is in player unit, not in voxel unit. The player unit is 256.0 units for a voxel.

The actual limit is 5000 units.

Best regards,
The Blackvoxel Team

Navigation

[0] Message Index

Go to full version