/** * @brief Updates player animations and movements. **/ public override void OnSyncedUpdate() { // Set a velocity based on player's speed and inputs TSVector velocity = tsRigidBody.velocity; if (TrueSyncInput.GetByte(INPUT_KEY_JUMP) > 0 && log) { startPosition = TrueSyncInput.GetTSVector(INPUT_MOUSE_POS); move = true; log = false; } if (TrueSyncInput.GetByte(INPUT_KEY_JUMP) < 1 && move) { endPosition = TrueSyncInput.GetTSVector(INPUT_MOUSE_POS); direction = endPosition - startPosition; velocity = direction / 10; move = false; log = true; } // Assigns this velocity as new player's linear velocity tsRigidBody.velocity = velocity; }
void Movement() { TSVector movement = TrueSyncInput.GetTSVector(INPUT_MOVE); TSVector velocity = rigidBody.velocity; velocity.y = 0; rigidBody.velocity = movement * MovementSpeed; //rigidBody.AddForce (movement * MovementSpeed - velocity, ForceMode.Impulse); }
/** * @brief Updates ball's movements and instantiates new ball objects when player press space. **/ public override void OnSyncedUpdate() { TSVector tapLocation = TrueSyncInput.GetTSVector(INPUT_TAP_LOCATION); // Take tapLocation and calculate what to do if (tapLocation != TSVector.zero) { OnTapLocation(tapLocation); } UpdatePlayerPosition(); }
public override void OnSyncedUpdate() { Movement(); Gravity(); tsTransform.LookAt(TrueSyncInput.GetTSVector(INPUT_LOOKAT)); if (TrueSyncInput.GetInt(INPUT_FIRE) == 1 && canFire) { Fire(); } }
/// <summary> /// The function to recieve and act upon input given in the onsyncedInput function. /// </summary> public override void OnSyncedUpdate() { if (running && unitcomscript.output == true) { foreach (AIController gam in aicontrollers) { gam.SpecUpdate(); } } if (unitcomscript) { unitcomscript.Timeleft -= TrueSyncManager.DeltaTime; } if (TrueSyncInput.GetInt(100) == 1) { if (running == false) { Debug.Log("start"); // running = true; managerstart(); } } int photon = 3000; TSVector pos = new TSVector(0, 0, 0); int target = 3000; FP averagespeed = 1; int check = TrueSyncInput.GetInt(0); bool waypoints = false; if (check == 0) { int limit = TrueSyncInput.GetInt(1); if (limit > 0) { for (int a = 2; a < limit;) { photon = TrueSyncInput.GetInt((byte)a); a++; Debug.Log(photon + " out of " + a); pos = TrueSyncInput.GetTSVector((byte)a); a++; target = TrueSyncInput.GetInt((byte)a); a++; averagespeed = TrueSyncInput.GetFP((byte)a); a++; waypoints = TrueSyncInput.GetBool((byte)a); a++; if (photon != 3000) { GameObject gam = null; if (PhotonView.Find(photon)) { gam = PhotonView.Find(photon).gameObject; } GameObject targetgam = null; if (target != 3000 && PhotonView.Find(target) != null) { targetgam = PhotonView.Find(target).gameObject; } if (gam) { gam.GetComponent <_Ship>().asignMoveOrder(pos, targetgam, averagespeed, waypoints); } } } } } else if (check == 1) { int b = TrueSyncInput.GetInt(1); if (b != 0) { spawnshipfun(b, TrueSyncInput.GetTSVector(2), TrueSyncInput.GetInt(3), TrueSyncInput.GetInt(4)); } } }