FaceTowards(target) time delay?

edited February 2018 in General

So my hero, deku from hero academia has an ultimate ability that makes him punch.

The problem is that the projectile is cast in the wrong direction if the unit first has to reposition himself to face towards the point the player has clicked.

the code i use for this is the ofllowing :

--turn hero in right direction

local direction = caster:GetForwardVector()

    -- wind effect
    Timers:CreateTimer(particle2_delay, function()
        -- Create projectile
            local projectileTable =
                EffectName = "particles/units/heroes/hero_windrunner/windrunner_spell_powershot.vpcf",
                Ability = ability,
                vSpawnOrigin = caster_position,
                vVelocity = Vector(direction.x * powershot_mov_speed, direction.y * powershot_mov_speed, 0),
                fDistance = range,
                fStartRadius = width,
                fEndRadius = width,
                Source = caster,
                bHasFrontalCone = false,
                bReplaceExisting = true,
                iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY,
                iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES,
                iUnitTargetType = DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC,
                iVisionRadius = width,
                iVisionTeamNumber = caster:GetTeamNumber()
            local powershot_projectileID = ProjectileManager:CreateLinearProjectile( projectileTable )

so i assumed that FaceTowards takesa certain amount of time to complete and is non blocking, so when my code asks for hero:GetForwardVector, midoriya is still in the process of turning. Could this be correct?


  • Try this. local direction = (target:GetOrigin() - caster:GetOrigin()):Normalized()

  • edited February 2018 Posts: 413

    I'm assuming target is actually a vector. local direction = ((target - caster:GetAbsOrigin()) * Vector(1, 1, 0)):Normalized()

  • Posts: 329

    awsome! this worked, thanks guys