bool CheckMovementValidLand(Vector3 movement) { //DodgeNeighbours(ref movement); float deltaTime = (this is AiPhysicsCharacterMotor) ? Time.fixedDeltaTime : Time.deltaTime; Vector3 newMovement = movement; newMovement.y = 0.0f; Vector3 deltaMovement = newMovement.normalized * maxForwardSpeed * deltaTime * 10.0f; //Vector3 nextFeetPos = transform.position + transform.forward * radius + deltaMovement; //if (!AiUtil.CheckPositionOnGround(nextFeetPos, 5.0f, AiManager.Manager.groundedLayer)) // return false; Vector3 nextPos = aiObject != null ? aiObject.center : transform.position; nextPos += transform.forward * radius; nextPos += deltaMovement; if (AiUtil.CheckPositionUnderWater(nextPos)) { return(false); } return(true); }
void OnTerrainColliderCreated(IntVector4 node) { if (node.w == 0) { IntVector2 mark = new IntVector2(node.x, node.z); if (!mExists.Contains(mark)) { if (Random.value < probability) { Vector3 pos = AiUtil.GetRandomPosition(node); if (AiUtil.CheckPositionOnGround(ref pos, 0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w, AiUtil.groundedLayer)) { if (!AiUtil.CheckPositionUnderWater(pos)) { GameObject faece = Instantiate(GetRandomFaeces(), pos, Quaternion.identity) as GameObject; faece.transform.parent = transform; mFaeces.Add(faece); StartCoroutine(DestroyFaece(faece, 400.0f)); } } } mExists.Add(mark); } List <GameObject> faeces = mFaeces.FindAll(ret => MatchFaece(node, ret)); foreach (GameObject ite in faeces) { Vector3 pos = ite.transform.position; float distance = pos.y - node.y; if (distance > PETools.PEMath.Epsilon) { RaycastHit hitInfo; if (Physics.Raycast(pos + Vector3.up * 0.1f, Vector3.down, out hitInfo, distance, AiUtil.groundedLayer)) { if (ite.GetComponent <Rigidbody>() != null) { ite.GetComponent <Rigidbody>().useGravity = true; } } } } } }
int GetPathIDFromSPID(int spid) { int tid = typeID; if (mTDInfo != null) { if (mType == PointType.PT_Water && !AiUtil.CheckPositionUnderWater(mTDInfo.position)) { tid = 4; } if (Mathf.Abs(position.y - mTDInfo.position.y) > 64.0f) { tid = 4; } } return(AISpawnPath.GetPathID(spid, tid)); }