Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question You Seek Yoda

Discussion in 'Physics' started by FrozenBurritos, Jan 22, 2022.

  1. FrozenBurritos

    FrozenBurritos

    Joined:
    Jan 4, 2018
    Posts:
    3
    Looking for a guru to help me understand world physics and object rotation. Having trouble instantiating objects and getting them to fly in the direction of where the player is facing. right now they seem to have a mind of their own and I am getting sleepy. At the moment the shooting action is better for a blooper real.

    Am trying to apply a skills based shooting mechanism instead of target locking all the time. Can provide code, discord, or even code sharing session. Don't all jump at once!

    This is the code that I am working with, it actually works better once the player is in motion, and I think I have it setup where all the objects are rotated properly when spawning in.

    anim.SetTrigger(AnimHashValues.SpellCast);

    GameObject spellObj = Instantiate(SpellToCast, this.transform.position + this.transform.forward, this.transform.rotation);
    spellObj.GetComponent<Rigidbody>().AddForce(this.transform.forward * 1000);


    However, most shots just shoot harmlessly at the floor.