Search Unity

Raycast from another object towards mouse click?l

Discussion in 'Scripting' started by cinderousrex, Sep 20, 2019.

  1. cinderousrex

    cinderousrex

    Joined:
    May 21, 2019
    Posts:
    43
    I have my main camera that fires a laser/linerender where it clicks.

    my goal is to have a separate object (such as another character) point exactly where I aimed my mouse from the main camera.

    I cant find an example of a separate object outside of your camera making a line render to the point you clicked your mouse.
     
  2. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    Why not simply set the origin of the raycast/linerenderer to the position of your object?
     
  3. cinderousrex

    cinderousrex

    Joined:
    May 21, 2019
    Posts:
    43
    I had been doing that and ran into bugs, turns out it was working fine just my linerendererer was not. Thanks for helping anyways! Thank goodness for Debug.Log()
     
    Dextozz likes this.