Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Recommended Posts

Some functions you'll probably use for shooting arrows include - Instance(), SetPosition(), SetRotation(), AddForce(),SetCollisionType(), SetMass()

 

Shooting arrows works like this in my game, Hunt For Food -

 

function Script:ShootArrow()
local arrow=self.arrow:Instance()
arrow.script.livetime=Time:GetCurrent()+15000
arrow.script.active=true
arrow:SetMass(.5)
arrow:SetPosition(Transform:Point(0,0,.75,player.camera,nil))
arrow:SetRotation(-player.camRotation.x-90,player.camera:GetRotation(true).y+180,-player.camRotation.z)
arrow:AddForce(0,1250,0,false)
end

 

I should also note that my arrows have a script to deal damage on collision. The script looks something like this -

 

function Script:Collision(entity,position,normal,speed)
if self.active==true then
self.active=false
if entity.script then
if entity.script.hurtable==true then
 self.entity:SetCollisionType(Collision.None)
 self.entity:SetMass(0)
 self.entity:SetShape(nil)
 self.entity:SetPosition(position)
 self.entity:SetParent(entity)
 if entity.script.health>0 then
 entity.script:Hurt(math.random(5,8.5),player)
 end
 self.livetime=Time:GetCurrent()+3000
end
end
end
end

 

I hope this helps!

  • Upvote 3
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...