Jump to content

[Scripting] how to check if the PC is on ground or hovering?


Nymra

Recommended Posts

Posted

soooo, I basically have an X Marker that is used as a vehicle to set the PC in place.

 

at times I have to detach the vehicle and I want to make sure, that the PC is back on the X marker before setting the vehicle again.

So I use:

 

"PlayerRef.MoveTo(vehicle)"

 

in this case the PC will be teleported in the air above the x marker and then fall down.

So if I set "PlayerRef.SetVehicle(vehicle)" directly afterwards, the PC will be floating in the air...

 

so two questions:

 

can I somehow move the PC to the spot ON the ground? like adding angles to the MoveTo? and which ones would I need? I dont understand where MoveTo moves to... meaning at which height. 

 

OR can I somehow check/bool if the PC is in the air and then just wait for it to be NOT in the air anymore

 

"PlayerRef.MoveTo(vehicle)"

 

while PCisIntheAir()

wait(0.1)

endwhile

 

"PlayerRef.SetVehicle(vehicle)"

 

 

thx alot again :D

 

 

 

Posted
1 minute ago, Scrab said:
PlayerRef.MoveTo(vehicle)
Utility.Wait(2) ; Howeverlong it takes for the player to fall
PlayerRef.SetVehicle(vehicle)

 

 

hehe, well, that is exactly the way it is setup right now :D even with the 2 seconds wait
I just wondered if there is a quicker and more precise way to do it. 

 

Posted
5 minutes ago, Nymra said:

I just wondered if there is a quicker and more precise way to do it. 

You could try

 

PlayerRef.MoveTo(vehicle)
float cZ = 0.0
While(cZ != PlayerRef.Z)
	cZ = PlayerRef.Z
	utility.Wait(0.1)
EndWhile
PlayerRef.SetVehicle(vehicle)

 

Posted
2 minutes ago, Scrab said:

You could try

 

PlayerRef.MoveTo(vehicle)
float cZ = 0.0
While(cZ != PlayerRef.Z)
	cZ = PlayerRef.Z
	utility.Wait(0.1)
EndWhile
PlayerRef.SetVehicle(vehicle)

 

 

uuh, neat :D
will try that, thank you!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...