Orbz Waypoint Help!
SAP_Apps
Member Posts: 77
@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.
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
vectorToAngle(tagetX - positionX, targetY - positionY)
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.
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.
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. 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.
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.