SmoothMovement for Projectiles

Options
Hello everyone! I am trying to make my projectile extremely smooth when moving so I make it LERP rather than constantly "glitch" move by jumping it's coordinates.

My Projectile is here: http://s30.postimg.org/fpg9r1sep/Untitled.png

SmoothSyncMovement class is here: http://pastebin.com/8fxG1pTy

Video of whats wrong: https://www.youtube.com/watch?v=1lJIafU ... e=youtu.be

Comments

  • vadim
    Options
    Hi,
    Looks like initial transform.position of projectile is zero.
    Do you set object position in PhotonNetwork.Instantiate() call?
  • Yes sir. I set it to a empty gameobject (which is directly in front of the player)
    PhotonNetwork.Instantiate("Fireball", spawnLoc.position, spawnLoc.rotation, 0)
    The problem is, is inside the SmoothSyncMovement script, it starts as zero:
    Vector3 correctPlayerPos; //We lerp towards this
  • vadim
    Options
    Initialize correctPlayerPos with initial object position in OnPhotonInstantiate handler.
    Or just skip lerping until first correctPlayerPos update arrived.
  • Soo would that be this:
    public void OnPhotonInstantiate() {
    correctPlayerPos = transform.postion;
    //and same with rotation
    }

    or is that incorrect?:/
  • vadim
    Options
    Did you try this?
    Looks not bad.
  • Pulov
    Options
    What I do with projectiles aimilar to yours is to instantiate the physycs projectile in the clients pc with an RPC. With photontargets ALL. This way it instantiates at the same time and what you get is all the physycs calculated in the client side. It works superb for me.