Catapult projectile

Hello,

So I'm having an issue with projectiles in a catapult. I have two catapult players and each others needs to shoot the other one. It is a round based game with a one shoot posibilty (like poketanks). The problem I'm having is when instantiating my projectile in the catapults holder. the projectile is not shot immediately, it's only instantiated at the beggining of the round in the holder and only shot when the player presses the fire button. The problem i"m having is that when the master client is instantiated the projectile is in the right position but when the second player connects, his projectile is not seen by the master player, and also the master player now has 4 projectiles instantiated( 2 in the holder and 2 random on the map, parented to the holder), while the other client has nothing instantiated. i'm using RPC. Please help as this has been unsolvable for days now...
void Start(){
	myView.RPC("NormalProjectile",PhotonTargets.Others,1);
	}


void NormalProjectile(int numberOfShots){
		ProjectileClone = Instantiate(Projectile[0],LaunchCupPoint.position,LaunchCupPoint.rotation) as GameObject;
		shootCounter = numberOfShots; 
	}


When I shoot with the master also, when the projectile needs to respawn they respawn more times and all acros the map chaotically.
I've also tried PhotonTargets.All with no succes.

Thank you !

Comments

  • In your code, every client will call the RPC when this script starts. This script starts with any GameObject it's added to, no matter what it is.
    Maybe you should put the RPC into some "on click" method or something.
    Also, the RPC is not executed locally. It's sent to PhotonTargets.Others and that means, the client that calls the method will not do the same as everyone else. Maybe you want to use the method on all clients to spawn a shot.