mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
apply "tryFromAbove" parameter when finding ground
This commit is contained in:
parent
60f685dd70
commit
a84e5f38dc
1 changed files with 11 additions and 4 deletions
|
@ -317,11 +317,18 @@ namespace SanAndreasUnity.Behaviours
|
||||||
// raycast against all layers, except player
|
// raycast against all layers, except player
|
||||||
int raycastLayerMask = ~ Ped.LayerMask;
|
int raycastLayerMask = ~ Ped.LayerMask;
|
||||||
|
|
||||||
Vector3[] raycastPositions = new Vector3[]{ this.transform.position, this.transform.position + Vector3.up * raycastDistance }; //transform.position - Vector3.up * characterController.height;
|
var raycastPositions = new List<Vector3>{ this.transform.position }; //transform.position - Vector3.up * characterController.height;
|
||||||
Vector3[] raycastDirections = new Vector3[]{ Vector3.down, Vector3.down };
|
var raycastDirections = new List<Vector3>{ Vector3.down };
|
||||||
string[] customMessages = new string[]{ "from center", "from above" };
|
var customMessages = new List<string>{ "from center" };
|
||||||
|
|
||||||
for (int i = 0; i < raycastPositions.Length; i++) {
|
if (parameters.tryFromAbove)
|
||||||
|
{
|
||||||
|
raycastPositions.Add (this.transform.position + Vector3.up * raycastDistance);
|
||||||
|
raycastDirections.Add (Vector3.down);
|
||||||
|
customMessages.Add ("from above");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < raycastPositions.Count; i++) {
|
||||||
|
|
||||||
if (Physics.Raycast (raycastPositions[i], raycastDirections[i], out hit, raycastDistance, raycastLayerMask)) {
|
if (Physics.Raycast (raycastPositions[i], raycastDirections[i], out hit, raycastDistance, raycastLayerMask)) {
|
||||||
// ray hit the ground
|
// ray hit the ground
|
||||||
|
|
Loading…
Reference in a new issue