Thread: Vector
View Single Post
Old 06-07-2008, 09:38 PM   #33
ClichesAreSt00pid
User
 
Join Date: Jan 2007
Posts: 157

ClichesAreSt00pid has little to show at this moment (4)

Default

Great system, forced me to learn vjass too.

Anyways I'm having trouble with one thing that I just can't figure out. I want it to be like a "thrown" bouncy ball from a spell, and the velocity is calculated in XYZ, so how would I make the velocity take the ball towards the target?

I'm also trying to make it so any kind of collision will make it bounce, like trees and stuff, but it's tough and will take time. I'm using items (like vexorian did I think) to check it if you are wondering, just the actual Z height of different models is what makes it difficult.


Edit: Okay figured it out. I just did...well this in the creation part (and many other things, like making the trigger into a spell):

Collapse JASS:
    static method create takes nothing returns bouncyBall
        local bouncyBall b = bouncyBall.allocate()
        local location l = GetSpellTargetLoc()
        local location l2 = GetUnitLoc(GetTriggerUnit())
        local location l3 = PolarProjectionBJ(l2, 600, AngleBetweenPoints(l2, l))
        set b.position = vector.create(GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),75.0) //this is the thrower
      //  give the ball a starting velocity
        set b.velocity = vector.create((GetLocationX(l3) - GetLocationX(l2))*MOVE_PERIOD,(GetLocationY(l3) - GetLocationY(l2))*MOVE_PERIOD,600.0*MOVE_PERIOD)
        set b.ball = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'ewsp', 0.0,0.0,0.0)
      //  make it possible to change the unit's flyheight
        call UnitAddAbility(b.ball, 'Amrf')
        call UnitRemoveAbility(b.ball, 'Amrf')
        set balls[ballNum]=b
        set b.spot=ballNum
        set balls[ballNum].duration = 0
        set ballNum=ballNum+1

        call RemoveLocation(l)
        set l = null
        call RemoveLocation(l2)
        set l2 = null
        call RemoveLocation(l3)
        set l3 = null
        return b
    endmethod
ClichesAreSt00pid is offline   Reply With Quote