User Tools

Site Tools


4rpl:commands:movetowardscellandavoid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
4rpl:commands:movetowardscellandavoid [2022/03/31 17:28] – Enhancement of [Description] and mention that gravity is included Vertu4rpl:commands:movetowardscellandavoid [2022/03/31 18:42] (current) – [Description] Enhanced. And I learned that the existence of this API confused me A LOT Vertu
Line 6: Line 6:
  
 ===== Description ===== ===== Description =====
-Takes a starting 3D position (a vector) and generates a new 3D position that is moved towards the target map integer coordinates. The resulting point will not be displaced more than the delta argument.+Takes a starting 3D position (a 3-vector) and generates a new 3D position using two variables for the X and Z coordinates that can be used by [[SetUnitPosition]] to move towards the target location. The resulting point will not be displaced more than the delta argument.
   * The minHeight argument restricts how close, height wise, the resulting point can be to the terrain and/or creeper.   * The minHeight argument restricts how close, height wise, the resulting point can be to the terrain and/or creeper.
   * The checkRange argument is an integer that specifies how many cells outward to inspect when enforcing the minHeight. A value of 0 means to only check the map cell that the unit is currently occupying.   * The checkRange argument is an integer that specifies how many cells outward to inspect when enforcing the minHeight. A value of 0 means to only check the map cell that the unit is currently occupying.
Line 13: Line 13:
   * The checkPseudoTerrain argument is a Boolean indicating whether to look at invisible pseudo terrain (like from shields) for enforcing the minHeight.   * The checkPseudoTerrain argument is a Boolean indicating whether to look at invisible pseudo terrain (like from shields) for enforcing the minHeight.
  
-:WARNING:\\ +:NOTE:\\ 
-This API and [[MoveTowardsAndAvoid]] have "gravity" included. The value of this "gravity" is most certainly 0.10((Derived from how there is no "gravity" for a unit when using these API's for moving only upwards (when the unit is told to move to it's current cell at a specific height). Any lower movement than 0.10 cells upwards would cause the unit to slowly fall down until minHeight stops it and does so at speed dependent on how much lower the vertical change is to 0.10 as this "gravity" will be "stronger" than the unit's ability to move upwards, causing it to fall with minHeight being an intervention in this process.)) and is how units that use these API'still "fall" even without applying some kind of vertical motion using another MoveTowards API independently.\\ +To clarify, the only difference in this API and [[MoveTowardsAndAvoid]] is that you can independently specify an X coordinate variable and an Z coordinate variable while not needing Y coordinate variableThe generated next position will not be limited to the and Z axis unlike how other TowardsCell API'like [[RotateUnitTowardsCell]] tend to behave.\\ 
-Imagen that all MoveTowards API's create a 3-Vector version of the provided delta as (Dx Dy Dz) while in the process of calculating the next position. The sum of all 3 vectors (without allowing subtraction to occur) will be equal to the originally provided delta. For this API and [[MoveTowardsAndAvoid]], Dy will have 0.1 subtracted((However, I possess no confirmation to if this subtraction is factored in how Dx + Dy + Dz = <-delta for if it wasn't, the unit would not move by <-delta at most and not be the true maximum delta. Either it moves no more but never equal to <-delta or moves at most by ~exactly <-delta (which is currently what was and is being assumed).)) from it to mimic the downwards force of gravity.\\ +So be sure to avoid thinking of this API as being similar in behavior to the other TowardsCell API'or it will get very confusing very quickly.\\ 
-If Dy > 0, the unit will rise vertically.\\ +If you came to this API thinking it could generate a next position on only the X-Z axis's, a way to do so is to take the resulting V3 and set the Y-vector to the unit's Y-position.
-If Dy < 0, the unit will fall until it reaches <-minHeight above the terrain as utilized.\\ +
-The resulting Dy will be the vertical change of the unit at any time. So if your <-delta was 0.5 and the vector of direction was perfectly and only upwards, the V3 delta would be (0 0.4 0) and cause your unit to move upwards at a rate of 0.4 cells per frame.+
  
 ===== Examples ===== ===== Examples =====
4rpl/commands/movetowardscellandavoid.1648762092.txt.gz · Last modified: 2022/03/31 17:28 by Vertu