Help with math

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
I want to create a parabola that can be angled and does not depend on terrain, how would I do it?

2 examples:
HELP-1.jpg

(Yes my paint skills owns fucking hard)
 

Builder Bob

Live free or don't
Reaction score
249
With or without vJass?

Editing this post when I know


vJass version:
JASS:
library FunctionLibraryZ

globals
	private location Loc = Location(0., 0.)
endglobals

function GetTerrainZ takes real x, real y returns real
	call MoveLocation(Loc, x, y)
	return GetLocationZ(Loc)
endfunction

function GetUnitZ takes unit whichUnit returns real
	return GetTerrainZ(GetUnitX(whichUnit), GetUnitY(whichUnit)) + GetUnitFlyHeight(whichUnit)
endfunction

function SetUnitZ takes unit whichUnit, real newZ returns nothing
	local real x = GetUnitX(whichUnit)
	local real y = GetUnitY(whichUnit)
	call SetUnitFlyHeight(whichUnit, newZ - GetTerrainZ(x, y), 0.)
endfunction

endlibrary


GetUnitZ will give you a unit's height regardless of terrain height.
SetUnitZ will set a unit's height regardless of terrain height.

Using these functions you can create parabola functions regardless of terrain height.
 

Kenny

Back for now.
Reaction score
202
Save the units starting Z location into a variable.

During the callback function, set another variable to the current Z location of the unit.

then:

JASS:
set height = GetLocationZ(GetUnitLoc(u))

if height < start_height then
    set height = (start_height - height) + Parabola(move_dist,max_dist)
elseif height > start_height then
    if start_height + Parabola(move_dist,max_dist) <= height then
        set height = 0.00
    else
        set height = Parabola(move_dist,max_dist) - (height - start_height)
    endif
else
    set height = Parabola(move_dist,max_dist)
endif


Im pretty sure thats how it goes. I needed something like this for a spell a while back, it's not 100% smooth, but it looks better then normal i guess.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top