User Tools

Site Tools


4rpl:commands:bounceterraincollision

Index

BounceTerrainCollision

BounceTerrainCollision(<-currentPosition <-lastPosition <-includePseudoTerrain <-includeShield <-terrainStandoff <-reflectionScale) ->newLastPosition ->newPosition

Description

Calculates a bounce off of terrain. Given two positions that represent the current and previous positions of a moving object, this call will calculate a new position and previous position for the moving object. The new positions will calculate a colllision with any terrain and generate a reflection so that the moving object will appear to have bounced off of the terrain.

  • currentPosition: A vector for the current position of a moving object
  • lastPosition: A vector for the last position of a moving object. The currentPosition-lastPosition is used to determine a vector of motion for the object.
  • includePseudoTerrain: A bool indicating if pseudo terrain (invisible terran defined by some units) should be included in the collision calculations.
  • includeShield: A bool indicating if shields should be included in the collision calculations.
  • terrainStandoff: A float that gets added to the terrain height. This effectively raises the apparent 'surface' of the terrain for calculation purposes.
  • reflectionScale: A float that controls the scale of the reflection. A value of 1 makes the reflection the same as the input velocity. A value less than 1 damps the reflection and a value greater than 1 amplifies the reflection.

Note that if there is no terrain collision then the 'w' (the last) position in the resulting vectors will be 0 (false). It will be 1 if there was a collision. Also note that if there is no terrain collision then the resulting newPostion and newLastPosition will have x,y and z values that are equal to minFloat.

Examples

BounceTerrainCollision(<-position, <-lastPosition, false, true, 0.5, 1) ->nlp ->np
if (<-np.w)
   <-np ->position
   <-nlp ->lastPosition
endif

Index

4rpl/commands/bounceterraincollision.txt · Last modified: 2021/01/08 11:01 by 127.0.0.1