Jump to content
MysticDreidel

noob Q.

Recommended Posts

I am kinda knew to leadwerks and i have found a bow model i really like and i imported it and i was wondering how do u make it so u can use the bow and shoot arrows? srry im a noob but thx for the help good sirs/madams wink.png

Share this post


Link to post

Make sure that you study the documentation and take as many tutorials as you can google. Take some tutorials on lua coding. Studying the scripts that come with Leadwerks is a real good start. There is a chance that someone here may have some bow and arrow code to share with you. Welcome to Leadwerks

Share this post


Link to post

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!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...