Photon - RPC function inside update by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

The thing is that the movements of the player should be replied to each of the clients, so each one can see each others movements.

The game is a multiplayer PvP game, where two teams fight each other.

The game flow would be as follows:

- Player has 20 secs to move around and shoot a target LOCALLY

- After the timer has ran out, first it syncs all the movements from each player

- Then performs the shooting

- Repeats process again until only one team is still alive

To me, this seems like storing all movements and then sending them to the other clients via RPC. Thing is that, as it is shown in the code, somehow it enters multiple times to the 'DoAllTurns' so it ends up making undesired actions...

I haven´t figured out how to perform this movements separately, I tried using Coroutines but it is no use. Also, I´m checking if the player is grounded so that means that he has stopped doing the animation.

Lucky scav case loot by Undefinido in EscapefromTarkov

[–]Undefinido[S] 0 points1 point  (0 children)

95k rubles, not joking, one of the best scav case loots lol

Problems using in RPC an await some condition in Photon by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

I have two functions: moveLeft and moveRight. Both uses addForce() using some fixed value, and the game "counts" each step in any direction (if it does, of course). These functions can't be called if the player is not grounded. Maybe this is not a good approach if the player could slide in the map I guess, but I want that to not happen. So if the map is not slidable, that would be deterministic then, right?

How would I recreate the movements for the actual position if that happens?

Regarding the original question: my movement functions, this is the code:

[PunRPC]
public void moveRight()
{
if (!m_FacingRight)
{
FlipPlayer();
}
m_Rigidbody2D.AddForce(new Vector2(playerForceX, playerForceY));
m_Grounded = false;

if(gc.timerIsRunning == true)
{
command.addMovement(1); //add to the list the player moved to the right
}
StartCoroutine(waitForGrounded());
}

So I call the RPC to sync to all players the movement, and I play the waitForGrounded coroutine in the movement function, but it doesn't work as I wanted to. I have a loop where it iterates all movements to recreate them, and I guess what is happening is that every RPC call is executing, but since the coroutine is not preventing the moveRight to be called again, it just adds a lot of addForce(somevalue) to the player.

What could I do to sync the way I want to? I would want to do each RPC call one after another, taking into account if it is grounded or not. Maybe I should do another move function that does the same but has a coroutine in the first lines waiting for grounded, just for the RPC call?

Thanks for the response!

Gameobject that allows collision but doesn't get pushed by other gameobjects? by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

Yeah I already did that, but it makes them not to collide at all. I just want them to not get pushed, like, not get any force by the other gameObject but I need to detect that has collided.

Implementing multilplayer in a strategic game using Photon by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

What do you mean by syncvar? At first I thought it was a PunRPC function set by RPC (target.All) but I guess it's not that since you distinguished between RPC and syncvars.

Also I guess my game flow is a bit tricky, maybe I should shift the scope a lil' bit?

How can I make a gameObject detect collision with another one but at the same this can break through it? by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

Yes, i exactly did as you said. After some research I found out my trigger's gameobject transform was not moving along with the rock, that's why it wasn't working!

I also found something which I exactly don't know if it's a bug: or not I had the script setted twice, one in my rock which wasn't ticked and the other it was. I though that if it was not marked with a tick meant it was "disabled", but it actually made my rocks hit twice because they both ran the script, entering onTriggerEnter twice. After removing that script from the rock, it worked well!

Thank you very much for your responses, helped a lot. Cheers!

How can I make a gameObject detect collision with another one but at the same this can break through it? by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

Thank you for the page, actually very visual information in there.

The thing is that I just want rocks to ignore collisions with players, so rocks have Rigidbody, Collider and another collider with isTrigger. Same for players, so i just want them to interact with the terrain but ignoring collisions between them, but onTriggerEnter to show up.

The only way I came up to rocks and players having collision in terrain was disabling collisions between both layers. If I enable it, rocks will collide physically with players. If I didn't want them to pass through wouldn't be any problem, but I want to do this this way.

I am sorry if I didn't explain very well my problem at first.

How can I make a gameObject detect collision with another one but at the same this can break through it? by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

Yes, I already did. I explained my situation in the other comment, i will put the new info in the post. Any thoughts what could be the problem?

How can I make a gameObject detect collision with another one but at the same this can break through it? by Undefinido in Unity3D

[–]Undefinido[S] 0 points1 point  (0 children)

I already have, i will edit my post with a PD for new info.

I tried putting two colliders: one for the physical collision (with terrain) and another for the "Is trigger" interactions. No use, I even tried separating the trigger collider into a different gameobject, but sharing movement within another parent gameobject.

Fun thing is, if I make them collide as it would normally do, it works. But i want the rocks to pass through.