I am trying to make a hit up to a down slam, however the down velocity is very weird, sometimes going a bit to the right, and sometimes going straight up left or right. I’m trying to make it go forward/backward instead of those two X directions
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(10000, 10000, 10000)
bv.Velocity = Vector3.new(0, 80, 0)
bv.Parent = enemy.HumanoidRootPart
wait(0.4)
local up = Vector3.new(0,70,0)
local forward = Vector3.new(0,0,30)
bv.Velocity = Vector3.new(0,-45,20)
wait(0.5)
bv:Destroy()
local playerEnemyDirection = (enemyHumanoidRoot.Position - playerHumanoidRoot.Position).Unit -- This line of code gets a *direction* which is important when making things relative.
bv.Velocity = Vector3.new(0,-45,0) + playerEnemyDirection * 10--How far you want it to go
You have to get the player’s and the enemy’s HumanoidRootPart for this to work.
Then you can create a direction vector from the player to the enemy. To create a direction simple do (Position1 - Position2).Unit for a direction from position2 to position1.
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(10000, 10000, 10000)
bv.Velocity = Vector3.new(0, 80, 0)
bv.Parent = enemy.HumanoidRootPart
wait(0.4)
local up = Vector3.new(0,70,0)
local forward = Vector3.new(0,0,30)
local playerEnemyDirection = (enemy.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Unit -- This line of code gets a *direction* which is important when making things relative.
bv.Velocity = Vector3.new(0,-45,0) + playerEnemyDirection * 10--How far you want it to go
wait(0.5)
bv:Destroy()
That might be because it is relative to where the player is currently. If you want it to be where the player was before you need to get the direction from the player to the enemy when you activate the move.
You need to push enemy related to attacking player look vector:
--attackingPlayer value is player who did this attack
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(10000, 10000, 10000)
bv.Velocity = Vector3.new(0, 80, 0)
bv.Parent = enemy.HumanoidRootPart
wait(0.4)
bv.Velocity = attackingPlayer.HumanoidRootPart.CFrame.LookVector*20+Vector3.new(0,-45,0)
wait(0.5)
bv:Destroy()