Author Topic: Programmatic handling of the player  (Read 10068 times)

Yves

  • Newbie
  • *
  • Posts: 9
    • View Profile
Programmatic handling of the player
« on: February 27, 2019, 07:08:48 pm »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Programmatic handling of the player
« Reply #1 on: November 28, 2019, 12:46:58 am »
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

  • Administrator
  • Jr. Member
  • *****
  • Posts: 68
    • View Profile
Re: Programmatic handling of the player
« Reply #2 on: November 30, 2019, 02:21:30 pm »
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