Barebones projectiles library, shotting stright.


I would like to know if i can shoot projectiles stright forward, from point with fixed vector. After fiev hours of digging and testing all i could do is some semi working thing.
A projectile that is shoot from hero in some direction, if mouse is over highground, projectile folows the ground, moves up with the ground than moves back to 0, even with the bGroundLock = false.
All i want is a projectile that goes stright with a given vector.


  • You have to set GroundBehavior to PROJECTILES_DESTROY or PROJECTILES_NOTHING

    Overall I don't recommend using that library. It is too specific and it is easier to write your own than adapting to the given one.

  • So what do you recomend for moving the particles, projectiles etc ? Do you think using the Dota API's ProjectileManager is worth a shot ? Or just a homemade raycasting with some tinker check for colision ? I have no idea myself, lua and dota's api are new for me... and poorley documented...

  • edited September 2015 Posts: 94

    The Dota ProjectileManager is only for simple linear and tracking projectiles with only 2D behavior. If that is all you need you can use it.

    If you need more advanced movement, something like

    function Projectiles:Create(particle, origin, velocity, acceleration, pCP, vCP)
        local projectile = {} = ParticleManager:CreateParticle(particle, PATTACH_CUSTOMORIGIN, nil)
        projectile.position = origin
        projectile.velocity = velocity
        projectile.acceleration = acceleration
        projectile.positionCP = pCP
        projectile.velocityCP = vCP
        projectile.destroy = false
        ParticleManager:SetParticleControl(, pCP, projectile.position)
        ParticleManager:SetParticleControl(, vCP, Vector(projectile.velocity,0,0))
            if projectile.destroy
                ParticleManager:DestroyParticle(, false)
            projectile.velocity = projectile.velocity + projectile.acceleration
            projectile.position = projectile.position + projectile.velocity
            -- your calculation and collider stuff here
            -- EXAMPLES:
            -- ground:
            if GetGroundHeight(projectile.position, nil) >= projectile.position.z then projectile.destroy = true end
            -- entities:
            local collision = Entities:FindInSphere(nil, projectile.position, 100)
            if collision[1]
                -- check for entity classes you want to trigger certain stuff
                projectile.destroy = true
            ParticleManager:SetParticleControl(, pCP, projectile.position)
            ParticleManager:SetParticleControl(, vCP, Vector(projectile.velocity:Length(),0,0))
            return 0.03

    should be a good basis and you can implement whatever behavior you want with it.

    I built a very complex physics-driven projectile system like that, it is all up to you how far you want to extend it.

  • Thanks a lot,
    It seem simple for me, and the example is very nice too.