ExecuteCommand Is it possible to organize any additional checks so that the method works correctly

RuslanRuslan
edited June 9 in BOLT Engine
Hello, sorry for the trouble, but I can not understand.

For archery I use the method
public override void ExecuteCommand

I also use
IsFirstExecution

But still shooting does not work correctly, at the client instead of one arrow several

Is it possible to organize any additional checks so that the method works correctly?


//Code


public override void ExecuteCommand (Bolt.Command c, bool resetState)
		{
			if (state.Dead) {
				return;
			}

			PlayerCommand cmd = (PlayerCommand)c;

			if (resetState) {
				_motor.SetState (cmd.Result.position, cmd.Result.velocity, cmd.Result.isGrounded, cmd.Result.jumpFrames);
			} else {
				// move and save the resulting state
				var result = _motor.Move (cmd.Input.forward, cmd.Input.backward, cmd.Input.left, cmd.Input.right, cmd.Input.jump, cmd.Input.yaw);


				cmd.Result.position = result.position;
				cmd.Result.velocity = result.velocity;
				cmd.Result.jumpFrames = result.jumpFrames;
				cmd.Result.isGrounded = result.isGrounded;



				if (cmd.IsFirstExecution) {
					// animation
					AnimatePlayer (cmd);

					// set state pitch
					state.pitch = cmd.Input.pitch;
					state.weapon = cmd.Input.weapon;
					//Выключили прицеливание класическое
					//state.Aiming = cmd.Input.aiming;
                             
//Calling the method of shooting

					if (cmd.Input.fire) 
					{

						//ArrowFire ();
	
				}
				}

				if (entity.isOwner) {
					cmd.Result.Token = new TestToken ();
				}
			}
		}




	//Shooting Method
		void ArrowFire(){
			if (Timer <= 0) { //нажатия ЛКМ


				var Arrov = BoltNetwork.Instantiate (BoltPrefabs.Arrow, ArrowPos.transform.position,ArrowPos.transform.rotation);
			    Arrov.GetComponent<Rigidbody>().AddForce(transform.forward* ForceScale); 

				Timer = Reload; //устанавливаем таймер например на 2 сек


			}

		}



Comments

Sign In or Register to comment.