+ Reply to Thread
Results 1 to 3 of 3

Thread: Another vector help thread

  1. #1
    Wirererer dpidcoe is on a distinguished road dpidcoe's Avatar
    Join Date
    Apr 2008
    Location
    san diego
    Posts
    174

    Default Another vector help thread

    I made a turret that'll point at a target using vector thrusters (basically a bar with a negative mult on one end and and positive mult on the other). The eventual goal is to stick it on a spaceship where it can cover a 180 degree bubble, a similar turret on the reverse side will cover the other half.

    I want it to work so it points along the axis of the ship if the target is outside of the 180 bubble, and point at the target if it can hit it. I can make it point along the ships axis just fine, but where I'm running into problems is on how to tell if it'll intersect with the ship.

    Currently I have the vector of the ship and the vector to the target to work with. Heres a picture of what I'm talking about:

  2. #2
    Master of Mars
    Magos Mechanicus will become famous soon enough Magos Mechanicus's Avatar
    Join Date
    May 2008
    Posts
    717

    Default Re: Another vector help thread

    One fairly easy way to do this is to find a vector that is always normal to the ship wall. For instance, you can place an E2 gate on the wall and use its entity():up() vector. Then you take the vector from the turret to the target and project it onto that normal vector. If the projection has a positive length, the target is inside that hemisphere.
    Code:
    Normal=entity():up()#Or some other one you find.
    Projlength=Totarget:dot(Normal) 
    #The vector projection is Projlength*Normal, but we only really need the length
    if(Projlength>0){Target normally}else{Face forward}
    
    I can wire anything directly into anything! I'm the Professor!
    -Professor Hubert Farnsworth

  3. #3
    Wirererer dpidcoe is on a distinguished road dpidcoe's Avatar
    Join Date
    Apr 2008
    Location
    san diego
    Posts
    174

    Default Re: Another vector help thread

    That worked near perfectly, thanks.

+ Reply to Thread

Similar Threads

  1. Second Longest Thread Ever (junk thread)
    By Jat Goodwin in forum Off-Topic
    Replies: 3395
    Last Post: 1 Hour Ago, 12:31 PM
  2. CPU/GPU bug thread
    By Azrael in forum CPU & GPU Tutorials & Programs
    Replies: 50
    Last Post: 11-14-2008, 06:01 PM
  3. Vector Thruster Vector Input
    By Captain Maim in forum Help & Support
    Replies: 10
    Last Post: 11-03-2008, 01:01 PM
  4. Outputting a vector from expression to vector thruster
    By Paper Clip in forum Help & Support
    Replies: 2
    Last Post: 10-16-2008, 03:37 AM
  5. Vector Thrusters and Vector Direction with a Pod
    By zentiger in forum Help & Support
    Replies: 8
    Last Post: 09-25-2008, 11:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts