Orbz Waypoint Help!

@ORBZ

Hey guys! Was messing around with a template today, ORBZ Waypoint... Sooooo the desired effect I was trying to accomplish using this template... was essentially the same... but making it more CRISPER. I am wanting to have the actor move to the waypoints in order like they are, but change direction EXACTLY at the waypoint middle and and start moving toward the next one.. no like arc of acceleration.

IE, waypoint at the same Y value at different sides of the screen. if i am coming at it from one direction then itll start going to the next one and itll arc around and start headin towards the next point. I want it to be exact.

Comments

  • ORBZORBZ Member Posts: 1,304
    At the point it comes into contact with the waypoint use Change Velocity instead of Accelerate to move towards the next waypoint. Use vectorToAngle to compute the target angle.

    vectorToAngle(tagetX - positionX, targetY - positionY)
  • SAP_AppsSAP_Apps Member Posts: 77
    At the point it touches the waypoint isn't the exact location of the waypoint so then it moves on to the next waypoint. I can't get the effect im goin for.. im going for exact location waypoints and mkaing it look like straight moving along the x axis and the y when it goes down.
  • ORBZORBZ Member Posts: 1,304
    Alternatively. If you just want it to accelerate but still move in straight lines you can just set the linear velocity x & y to 0 when it comes into contact with a waypoint. That will make it move like a tank that has to pick up speed. Then stop instantly when it reaches its target.

    If you would like it to decelerate instead of stop instantly set the drag to a very high value for a second instead of canceling out the linear velocity completely when it touches a waypoint.
  • SAP_AppsSAP_Apps Member Posts: 77
    Replying just in case you missed my last reply. ;)
  • SAP_AppsSAP_Apps Member Posts: 77
    Like as of right now. I've got as soon as it overlap and collides with waypoint then change linear velocity x and y to 0. works mostly, but not exact because it stop when it collides with the waypoint and starts in new direction which is a few pixels off from making it a straight line
  • SAP_AppsSAP_Apps Member Posts: 77
    I thought to try more along the lines of individual waypoints, not near as automatic to yours... and use Move to... it works PERFECTLY as in move automatically to wx wy... once at wx and wy... move to wx2 wy2 etc etc... the effect is perfect. pixel perfect. goes in straight line... however, i cant do a simple thing as in STOP the actor mid motion and continue his motion once my stop button has been lifted..
  • ORBZORBZ Member Posts: 1,304
    edited June 2013
    oh, you want it to move in an L towards the next waypoint? Or if the two waypoints were perfectly lined up vertically or horizontally then it would just move in a straight line?
  • SAP_AppsSAP_Apps Member Posts: 77
    Move in a straight line and stop at the waypoints exact coordinates then proceed to the next waypoint. So it is perfect movement. No overshooting ane correcting slowly to the next waypoint if it accelerstes past
  • ORBZORBZ Member Posts: 1,304
    edited June 2013
    Gotcha.

    D = R/T

    So

    If you want to move a perfect distance at a constant speed you need to tweak the time.

    T = R/D

    Calculate the distance between the position you are and the position you want to be:

    Distance = magnitude(current.x - target.x, current.y - target.y)

    Specify a fixed speed:

    Speed = 100

    Calculate the time:

    duration = speed / distance

    For duration:
    Move towards target X Y at Speed

    After duration + 1s
    Move to next target.

    Repeat the process.


    That's the gist of it.
  • krustelkramkrustelkram Member Posts: 19
    Hi Orbz,

    I love your Waypoint Template and I am working through it to learn how it works. Beautiful work by the way, so smart and organized. I hated school and skipped it as much as I could especially math classes, so I am a mess. But wow you made me understand what the "VectorToAngle" Function really means and more important what it can be used for. :D Thanks!!

    But I can't figure out why the tank after hitting all the waypoints returns to waypoint number 0 and the loop begins.
    Also: In the Tank Actor the rule starts with:
    Attribute: game.Waypoint.count > 0
    So why does the tank even there hit Waypoint 0 first?

    I guess the answer lies in "Set the next waypoint":

    Change Attribute: game.WaypointTarget ID to ( self.ID +1)% game.Waypoint Count

    so what does % mean?
    Maybe that's a stupid question I am a noob, but I really would like to know why.
  • ORBZORBZ Member Posts: 1,304
    @krustelkram

    the % means modulus it's like division except you keep only the remainder. This is often used when you want to achieve a looping of numbers, say after 5 you want to return to zero so you would say x % 5 which means that when x is 1 then x % 5 = 1 and when x is 2 then 2 % 5 = 2, ..etc... until we hit 5 % 5 in which case the remainder is 0.

    In the example above the WaypointTargetID is set to the (self.ID + 1) % waypointCount this means that the game WayPointID is set to the NEXT id of the current object (aka self + 1) but then to wrap around back to 0 when we reach the maximum number of waypoints (aka waypointCount)

    In this way the waypoint id keeps shifting and repeating, 0... 1... 2... 3... 0... 1... 2... 3... 0... 1... 2... 3.... 0... etc.
Sign In or Register to comment.