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.
  2. Dismiss Notice

How to make a light be attached to an object? [UNSOLVED]

Discussion in 'Scripting' started by LightWell, Sep 10, 2014.

  1. LightWell

    LightWell

    Joined:
    Sep 6, 2014
    Posts:
    43
    Hey guys, I was wondering on how to make a light be attached to an object, so basically what I know has to happen is I have to get an object, and get the Vector3 location of it, and set that to the light, but I don't know how to do that, any help guys?

    Thanks in advance and for helping me so much already guys!

    ~ Light
     
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    you create a light in the scene, then drag it on to your game object. this is SUPER basic stuff. I suggest you do some tutorials in the learn section at the top.
     
    merkaba48 likes this.
  3. LightWell

    LightWell

    Joined:
    Sep 6, 2014
    Posts:
    43
    That's not what i meant, I meant to like have it stick to an object, like a headlight in a car game or such. I want it to track with the balls and paddle in a pong game I'm making (nice to start simple right?).
     
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Re-read what JamesLeeNZ told you. He gave you exactly the answer you need.
     
  5. LightWell

    LightWell

    Joined:
    Sep 6, 2014
    Posts:
    43
    Lol, I overthought this, well I ended up just setting a point light as a target and making it go to the vector location, but thanks :p.
     
  6. BmxGrilled

    BmxGrilled

    Joined:
    Jan 27, 2014
    Posts:
    238
    @LightWell as JamesLeeNZ stated, by dragging the light on to the "ball" you refer to as the headlight, you parent it's transform to the ball transform. When you rotate the ball transform, or move it, the light will follow it. I think you should do some reading on Transforms in Unity, a google search such as "Unity3D Transform" yields good results.

    ~
    Another walk in the park.