Who should call RPC function while hit by a bullet - unity3d

My question is simple.
Im creating top down 2D shooter game via PUN2 Free in Unity.
I want to synchronize collisions through network, to avoid lags inaccuracy.
A player is firing a bullet and it hits enemy. I want players to know about all bullets hits(to reduce health, get kill, etc.).
Should I call RPC_Hit() from shooter to other players to inform about actual hit or it would be more wise to call RPC_Hit() from hurt player to other players in game.
Im asking in terms of better synchronization, I guess lags will happen, so in my oppinion it would be better to call RPC function from player which got hit, but then if I would need to send callback only to shooter(for example, to let him now how many dmg he did) it would be hard, cause I can only send RPC to "MasterClient,All,Others".
This bothers me.
I can not find any informations about this.
In same moment the Player1 and Player2 view differs cause of Lag

Related

Client side prediction with a Shared object(Player - Ball relationship)

Our team is developing a football game. But we are stuck in a step.
We can't move forward because of this.
When we make client side prediction, the local player plays on the current time.
But the other objects like balls and other players play in the past(due to latency).
Normally for other objects we use interpolation but this doesn't work for the ball because local player interact with it while moving and it causes the other players to intertwine with the ball.
We tried to take the ball to the current state simulating physics and run all work-flow on the local. But this time when other players interact with the ball, they seems like moving the ball from far behind. Because of the other players in the past.
What is the best method to use for this situation?

Why player is lagging (local multiplayer)

Why my player lagging? I mean he is moving with 2 fps for enemy. Example: Player1 moves, in his screen all is ok. But player2 see player1 with 2 fps. And the same with player1.
Here is my prefab, and yes, I can't use RigidBody Transform
I think you could find the answer with very little research. The answer is quite simple though.
The reason why it's working perfectly on the client which owns the networking transform is because his input is directly reported to the game. On the other hand, the 2nd player has to send the information about his position to the host or simply the other players. The information is only sent a couple times per seconds.
You could increase the message sending rate of the networking but that's not really a good option. The best option would be to smooth the player's movement by assuming where he is going to be or move the player after it has moved already.
Here is a link about it : https://www.youtube.com/watch?v=Glm0nJ4sO5E

unity3d player gameobject "hear" sounds

I have a question that is a little... complex
basically I want a gameObject (an enemy) "listen" to the sound of the player (footsteps, door opening, gunfire etc)
I could do this just fine by using:
>Collider[] hitColliders;
>hitColliders = Physics.OverlapSphere(transform.position, 10f,enemyLayer);
>
>for(int i=0;i<hitcolliders.Length;i++){}// Call Enemy Hear Player Function
However, the problem starts here:
I want the "sound" to be blocked by walls. At first, I thought I could use Physics.Linecast to do this. However, this means the sound could be blocked by a mere piece of pole, because Physics.Linecast only shoots a single, straight line.
What I want is player C could not hear anyone at all, but player A and B could still hear each other.
I hope you guys understand my question.
You could place the objects you want to block the soundwave on a specific layer. And just make the raycast ignore all other layers.
Leave all this Physic and other graphical stuff behind.
Create a separate logic for this behavior.
Create a big chess board (where x,y will be x,y position in you game) and add only sound-generators, sound-listeners and sound-obstacles.
Update this chess board each frame and create sounds, fly sounds, block sounds and listen to sounds and act appropriate as the real life actors.
This way you can add parameters to each obstacle, sound-generator and sound-listener so that all be configurable.

Unity help, indie horror game

I am making a game using a combination of Blender and Unity and have hit a wall. I am trying to make it so a lamp flies off of a table and smashes against a wall once the player walks past a certain point in the map.
I am having a hard time with this. Any help is appreciated.
You need to break this up into little parts.
The first part is that once the player walks past a certain point you want to do something. To do this, look at http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
An on trigger event will let you run some code when an object collides with another object. In your case, when your player collides with a certain point in the game.
Next, inside that OnTriggerEvent, you want to fire the lamp off the table. To best do this, create a keyframe animation (or whatever you're most comfortable with) that animates the lamp to fly off the table. Lastly, play that animation in the trigger event. http://unity3d.com/learn/tutorials/modules/beginner/animation
To summarize, when the user hits a certain point, play an animation on the lamp.

Using GameCenter for parallel turn based games?

I've played around with making turn-based games using GameCenter. I understand that by default, GameCenter assumes that out of a number of participants, at any given time, one player holds the "play baton", and that this player is the only one who can affect the current game state. Gameplay is asynchronous, i.e. whoever's turn it is can take their time, and the other players will be notified once it's their turn.
So far, so good.
Now I want to use GameCenter to implement a similar, but slightly different kind of turn-based game: an asynchronous game where, instead of a serial player succession, players make their turns in parallel, which are then consolidated into a new game state once all players have "turned in" their moves.
A good model game for this would be Rock, Paper, Scissors: both players secretly decide on their move ("rock", or "paper", or "scissors"). The order in which those are then submitted to the server is arbitrary; i.e. no player should ever get a "not your turn"-type error when they try to submit a move in an ongoing round. Once they both turned in their moves, all player choices are revealed, and the winner of the current round is determined/declared.
The question is: is it possible at all to use the GameCenter infrastructure for this kind of game, either by design or by work-around? And if so, what would be considered a good approach?
It is not possible to implement this with Game Center the way you suggested, but you can take an approach that will look as if you did manage to do this.
When you start a turn-based match, it's always the local player's turn. Either Game Center provides you with a blank match, or you will receive a match in which someone else already took their turn. There is no way to control this, so you need to be prepared for both.
The approach you can take is to have a player always take their turn before you show them anyone else's move. Only then do you check if in your local case, everyone has now taken their turn and you show the result. This will provide the illusion of what you are asking for. In the case of Rock-Paper-Scissors you can now decide the match outcome. The other player will be notified.
However, if not everyone has taken their turn in this round, don't show anything, update the game state as well, but tell the user you're now waiting for others to take their turn. You will be able to show the result when you are notified that it's your turn again, with a game state already indicating the outcome.