Hey guys! I’ve been making steady progress with my game, I have basic multiplayer functionality at the minute, by this I mean one person can host and the other players can join his game, I’m thinking maybe doing all clients connecting to a proper server would’ve been better but I’m not sure.
I’ll go into depth a bit about my game type, It is a birds-eye Free-for-all arena game, you use click to move to control your character and will press keys to use skills to fight against other players online. There are no guaranteed hitting skills, everything must be aimed correctly whether it be a huge AoE or a small projectile.
Even though I’ve got this working I have a multitude of problems such as:
-
Movements are really laggy, not my movements of course but the other players I see are laggy (and they see me as the same!), when you’re playing as the host you only really see movement lag but when you play as the person connecting you see movement + projectile lag (such as multiple projectiles showing up instead of 1) I heard that this can be fixed by applying extrapolation/interpolation but I want an extra opinion on the simplest way to make these movements smoother without having to do anything TOO complex, I’m pretty new to Unity but not programming as a whole.
-
Struggling with certain things when it comes to having to depend on “networkView.IsMine” e.g. I have a skill that activates when a player hits the “W” key, because of the strength of the skill I don’t want players to be able to move while casting this so I do something like below on my playerattack script (which is attached to the Player prefab, along with the networkview component
but what happens is when another player is standing near me and I press “W” for the skill, they also are unable to move, here is the code for the skill itself and the code I have for stopping movement while casting the skill:
[RPC]
IEnumerator delayedRanged()
{
audio.PlayOneShot(shootSound2);
CTM.isCasting = true;
for (int i = 0; i < 40; i++)
{
myTransform.localScale *= 1.02f;
yield return new WaitForSeconds(0.05f);
}
Debug.Log("Done");
audio.PlayOneShot(shootSound3);
transform.localScale = originalScale;
clone = (Transform)Instantiate(projectile, transform.position, transform.rotation);
clone.localScale *= 20;
Physics.IgnoreCollision(clone.collider, transform.root.collider);
CTM.isCasting = false;
for (int a = 0; a < 20; a++)
{
clone.localScale /= 1.02f;
yield return new WaitForSeconds(0.05f);
}
}
/
if (networkView.isMine)
{
if (!isCasting)
{
myTransform.position = Vector3.MoveTowards(myTransform.transform.position, destination, Time.deltaTime * Speed); //move toward destination
}
}
These are my main two problems at the moment, I have a few others which I know how to fix myself but these two have me stumped, would really appreciate some tips/help, thanks!