Search Unity

Raycast from child object in forward direction

Discussion in 'Physics' started by Frogger007, Jan 2, 2016.

  1. Frogger007

    Frogger007

    Joined:
    Jun 24, 2014
    Posts:
    338
    I have a gameobject and a parented child object.
    A c# script is attached to the parent object.

    How can i send with this script a raycast in forward direction from the child object ?

    This script:
    1. public GameObject child;
    2. Physics.Raycast(child.transform.position, Vector3.forward, out hit, 25.0f);
    sends out only a raycast in the parent forward direction !
     
    Last edited: Jan 2, 2016
  2. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    Physics.Raycast(child.transform.position, child.transform.forward, out hit, 25.0f);
     
    Frogger007 likes this.
  3. Frogger007

    Frogger007

    Joined:
    Jun 24, 2014
    Posts:
    338
    Many thanks, this was a very important help for my project !
     
    Ysgramor likes this.
  4. EVECTOR

    EVECTOR

    Joined:
    Aug 13, 2019
    Posts:
    13
    Thank you @Ysgramour! Now "Acid Drones" will be able to kill player! ;)