// Start is called before the first frame update void Start() { physXSceneManager = FindObjectOfType <PhysXSceneManager>(); physXSceneManager.doPhysics = false; loadingScreenInstance = Instantiate(loadingScreenPrefab, transform.position, Quaternion.identity); Invoke(nameof(Begin), 3f); // Invoke(nameof(TestPhysics), 4f); }
public static bool Fire(Vector3 origin, Vector3 direction, float distance) { physXOrigin.FromVector(origin); physXDirection.FromVector(direction); if (defaultPhysXRaycastHit == IntPtr.Zero) { defaultPhysXRaycastHit = PhysXLib.CreateRaycastHit(); } return(PhysXSceneManager.FireRaycast(physXOrigin, physXDirection, distance, defaultPhysXRaycastHit)); }
public static bool Fire(Vector3 origin, Vector3 direction, float distance, PhysXCollider.CollisionLayer layers, uint ignoredVehicleId = 0) { physXOrigin.FromVector(origin); physXDirection.FromVector(direction); if (defaultPhysXRaycastHit == IntPtr.Zero) { defaultPhysXRaycastHit = PhysXLib.CreateRaycastHit(); } return(PhysXSceneManager.FireRaycastFiltered(physXOrigin, physXDirection, distance, defaultPhysXRaycastHit, (uint)layers, 0, 0, ignoredVehicleId)); }
public void ActivateVehicleInputs() { // check if the driver is a human or a bot // if they are a bot, then get the MASTER CLIENT to turn on ai controls if (botDriver && PhotonNetwork.IsMasterClient) { EnableMonobehaviours(aiDriverScripts); } // otherwise, find the driver player by their nickname. Tell their client to turn on player driver controls //Debug.Log("My local name is " + PhotonNetwork.LocalPlayer.NickName); TeamEntry team = gamestateTracker.teams.Get((short)teamId); if (team.name == null) { PlayerEntry driver = gamestateTracker.players.Get(team.driverId); PlayerEntry gunner = gamestateTracker.players.Get(team.gunnerId); GetComponent <TeamNameSetup>().SetupTeamName($"{driver.name} + {gunner.name}"); driver.Release(); gunner.Release(); } else { GetComponent <TeamNameSetup>().SetupTeamName("Team " + teamId); } if (PhotonNetwork.LocalPlayer.ActorNumber == driverId) { EnableMonobehaviours(playerDriverScripts); GetComponent <TeamNameSetup>().SetupTeamName(""); } //Debug.Log("GOT HERE"); // Do the same again for the gunner if (botGunner && PhotonNetwork.IsMasterClient) { EnableMonobehaviours(aiGunnerScripts); } if (PhotonNetwork.LocalPlayer.ActorNumber == gunnerId) { EnableMonobehaviours(playerGunnerScripts); GetComponent <TeamNameSetup>().SetupTeamName(""); } PhysXSceneManager physXSceneManager = FindObjectOfType <PhysXSceneManager>(); physXSceneManager.doPhysics = true; //Debug.Log("GOT HERE2"); Debug.Log("Spawn success"); GetComponent <DriverAbilityManager>().SetupDriverAbilityManager(); }
public static bool Fire(Vector3 origin, Vector3 direction, PhysXRaycastHit raycastHit, float distance, PhysXCollider.CollisionLayer layers, uint ignoredVehicleId = 0) { physXOrigin.FromVector(origin); physXDirection.FromVector(direction); bool hit = PhysXSceneManager.FireRaycastFiltered(physXOrigin, physXDirection, distance, raycastHit.physXRaycastHit, (uint)layers, 0, 0, ignoredVehicleId); if (hit) { raycastHit.PopulateFields(); } return(hit); }
public static bool Fire(Vector3 origin, Vector3 direction, PhysXRaycastHit raycastHit, float distance) { physXOrigin.FromVector(origin); physXDirection.FromVector(direction); bool hit = PhysXSceneManager.FireRaycast(physXOrigin, physXDirection, distance, raycastHit.physXRaycastHit); if (hit) { raycastHit.PopulateFields(); } return(hit); }
// public float distance { get; private set; } // public Transform transform { get; private set; } internal void PopulateFields(IntPtr vehicle, int wheelNum) { IntPtr hitActor = PhysXLib.GetGroundHitActor(vehicle, wheelNum); PhysXBody body = PhysXSceneManager.GetBodyFromPointer(hitActor); IntPtr shape = PhysXLib.GetGroundHitShape(vehicle, wheelNum); collider = body.GetColliderFromShape(shape); PhysXLib.GetGroundHitPosition(vehicle, wheelNum, _pxpoint); _pxpoint.ToVector(ref _point); }
protected void Awake() { collisionEnterEvents = new List <ICollisionEnterEvent>(GetComponentsInChildren <ICollisionEnterEvent>(true)); collisionStayEvents = new List <ICollisionStayEvent>(GetComponentsInChildren <ICollisionStayEvent>(true)); collisionExitEvents = new List <ICollisionExitEvent>(GetComponentsInChildren <ICollisionExitEvent>(true)); triggerEnterEvents = new List <ITriggerEnterEvent>(GetComponentsInChildren <ITriggerEnterEvent>(true)); triggerExitEvents = new List <ITriggerExitEvent>(GetComponentsInChildren <ITriggerExitEvent>(true)); sceneManager = FindObjectOfType <PhysXSceneManager>(); sceneManager.AddActor(this); }
internal void PopulateFields() { IntPtr hitActor = PhysXLib.GetRaycastHitActor(physXRaycastHit); PhysXBody body = PhysXSceneManager.GetBodyFromPointer(hitActor); transform = body.transform; IntPtr shape = PhysXLib.GetRaycastHitShape(physXRaycastHit); collider = body.GetColliderFromShape(shape); distance = PhysXLib.GetRaycastHitDistance(physXRaycastHit); PhysXLib.GetRaycastHitNormal(physXRaycastHit, _pxnormal); _pxnormal.ToVector(ref _normal); PhysXLib.GetRaycastHitPoint(physXRaycastHit, _pxpoint); _pxpoint.ToVector(ref _point); }
public static void AddScene(PhysXSceneManager scene) { scenes.Add(scene); }