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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

object rotating arround other shot out

Discussion in 'Scripting' started by Gilmur, Jan 19, 2016.

  1. Gilmur

    Gilmur

    Joined:
    Oct 19, 2015
    Posts:
    2
    i need that an object that its arround other shot out in straight line relative to diameter line like this picture:

    Remember that the object its rotating.

    Thx very much
     

    Attached Files:

  2. A.Killingbeck

    A.Killingbeck

    Joined:
    Feb 21, 2014
    Posts:
    483
    No such thing as a "Diameter" line? Your picture indicates you want it to just shoot at the other when it's close enough? A circle does not have a concept of "forward" so you're Diameter line can be an infinite number around the circle
     
  3. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    Than do it :D
    Post your code you have or the problem you have to start this :)
     
  4. Gilmur

    Gilmur

    Joined:
    Oct 19, 2015
    Posts:
    2
    sorry about my explanation heheh i just need when click the mouse
    • if(Input.GetMouseButtonDown(0)){
    the object2 shot out in straigh line relative to center of object1
    thx and sory about explanation
     
  5. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    First you need a reference to object1 , than spawn the bullet with the same rotation than object1 at position object2,

    don't know how your bullet movement script looks like, but you have to move your bullet with something like

    transform.position += transform.up * bulletspeed* Time.deltaTime;