Announcement

Collapse
No announcement yet.

Flying AI + Asteroids motoin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Angle between 2 vectors is arcus sin (or arc cos, not sure) of dot product of 2 normalized vectors.

    Leave a comment:


  • replied
    Originally posted by junkmail View Post
    now picking up a lot more targets.Thanks again
    That's great!

    Leave a comment:


  • replied
    Thanks for the help, while not perfect it is now picking up a lot more targets.
    Here's what I ended up with. I used find look at rotation instead of the function (fits into the existing macro).


    Learned a lot, got stuck up on the local vs world stuff. Added the (subtraction of local) for the rotator (delta) to give me local :-)

    Thanks again

    Leave a comment:


  • replied
    So what you need now is the "angle between two vectors" of current direction (predicted vector) and steering vector (vec. #3).

    https://answers.unrealengine.com/que...2-vectors.html

    Leave a comment:


  • replied
    @LazyMammal
    Is this what you are thinking? The values from 2. are really high how do convert to a rotation? (look at rotation?) I understand the subtraction of the ship to make it local, but not sure I get how to make that 3 my new angle.


    @nawrot I think you might not be simplifiing enough, my ship has no mass, has a capped speed, also not looking to stop it at the target as it's a race, I just need it to drive right over the target.

    Leave a comment:


  • replied
    Steering just in response to desired location will put ship into that dreaded pendulum state, you need to anticipate and calculate optimal steering ahead of time.

    Solving this is elementary school physics class problem (at least simple case of it). You have speed, mass of ship, and distance. You calculate acceleration you need to apply for it to stop. And F=mass * acceleration, so you have force needed. From this you can calculate time it takes to stop ship.

    All you need to next is repeating those calculations every second or so in case of random forces applied from other objects in game like collisions etc.

    Problems start when you want optimal steering instead of just any steering. For eg. fastest way to reach and stop at location.

    Leave a comment:


  • replied
    I made two mistakes. One I probably wasn't clear enough in my description. I meant both vectors *relative* to the ship's current location. Two, I got the formula wrong for vec. #3.

    Let's say:

    S = ship location (world)
    P = predicted location (world)
    D = desired location (world)

    In relative terms ...

    1) P - S
    2) D - S
    3) ???

    Now let's figure out what vec. #3 should actually be.

    We want to know what the *corrected steering* should be. Oh right. That's desired (relative) *minus* predicted (relative).

    3) D - S - (P - S)
    = D - P - S + S
    = D - P

    So it's the same as desired (world) minus predicted (world). Go figure.

    Leave a comment:


  • replied
    sum of 1+2 I'm trying but it just results in a spinny mess. Tried to get this to work now for a long time, any thoughts as to what I am doing wrong?

    The look at rotation node doesn't help either (instead of a vector + vector).

    Leave a comment:


  • replied
    There are 3 vectors to keep in mind:

    1) where ship will be *after* next time step.
    2) where you *want* the ship to go.
    3) the *DIFFERENCE* of 1+2

    Steer for vector 3 instead of vector 2.

    Edit: changed "SUM" to "DIFFERENCE". see my comment below
    Last edited by LazyMammal; 10-02-2015, 03:12 AM. Reason: changed "SUM" to "DIFFERENCE"

    Leave a comment:


  • replied
    Thanks for the reply, I'm not sure I have the math skills for a proper implementation. I'll ask my engineering friend about your recommendation.

    In the meantime, I implement hack solutions. I currently have a hack that looks at the angle my ship is from the target and I then apply hand-brake and if high enough cut thrust as well. But no matter the angles conditions that I set eventually the ship will end up circling a degree under my condition...

    How about this hack, moving the target to opposite(negative??) the vector of the ship in world space?

    Leave a comment:


  • replied
    Your space ship is victim of pendulum movment. This happens when turning or stopping and you understeer.
    I found solution to it but never successfully implemented it. This is not that easy.
    Proper implementation needs steering theory and all that laplace equations (which i do not dare to code in blueprints).

    First work with simple case that is linear motion, ie you want to stop (no turning) at some point.
    You start with 1/2*a*t*t equation that describes pendulum movement. I do not have my notes here, but out of it you get some equation with force, distance and speed.
    You need to find FORCE value that matches speed and distance to travel. Then you apply that force opposite to movement direction.

    Spaceship should stop right on the spot.

    Next step would be calculating that force every few ticks and adjusting steering.

    Then do vector math, find desired movement vector, counter both side drift and moving towards destination separately.
    Kill drift part with some major oversteering, and approach destination just like linear simple case above.

    I got it all to first simple case, but stopped working on AI then (it was fine for testing at that point).

    Leave a comment:


  • started a topic Flying AI + Asteroids motoin

    Flying AI + Asteroids motoin

    Hi,

    I've just started into the world of UE and have also decided to learn vectors at the same time.
    I'm integrating Peter L Newton's Flying AI into with asteroids (classic arcade) like motion into the checkpoint racing tutorial. However I have trouble with the steering of the AI. Essentially the steering never accounts for the existing physics motion of the "ship". So in some instances the ship will endlessly circle the target as I can't get the ship to 'over steer' to correct the 'drift'. My newly found basic understanding of vectors would suggest I need to do a vector - vector, which I tried and completely breaks the steering. My other thought is to Mirror the steering vector along the look at normal.
    Here's the existing steer



    I'm not using the physics engine I am using a 'world vector' to record my motion and apply 'thrust' AddWorldOffset to it in the yaw direction the actor is facing. Which is working great, again it's the steering that I can't seem to get my noodle around.

    Thanks for reading,

    Andrew
Working...
X