Jump to content

add model/entity to character


dennis
 Share

Recommended Posts

I just started a 3rd person type project and used the following code to attach a weapon to the players arm.

 

Add code to script attached to weapon. Adjust SetPosition and Setrotation as needed.

 

Script.Target = nil--entity "Player"
Script.gc = ""

function Script:Start()
self.gc = self.Target:FindChild("rHand") -- rHand is whatever name of bone
local gun = self.gc:GetPosition()

self.entity:SetParent(self.gc)
self.entity:SetPosition(gun.x-11,gun.y-2,gun.z+6)
self.entity:SetRotation(gun.x-110,gun.y,gun.z)

end

 

Didn't the Scene tree use to show the model Hierarchy? Could just drag the weapon to the bone then.

Elite Cobra Squad

Link to comment
Share on other sites

I just started a 3rd person type project and used the following code to attach a weapon to the players arm.

 

Add code to script attached to weapon. Adjust SetPosition and Setrotation as needed.

 

Script.Target = nil--entity "Player"
Script.gc = ""

function Script:Start()
self.gc = self.Target:FindChild("rHand") -- rHand is whatever name of bone
local gun = self.gc:GetPosition()

self.entity:SetParent(self.gc)
self.entity:SetPosition(gun.x-11,gun.y-2,gun.z+6)
self.entity:SetRotation(gun.x-110,gun.y,gun.z)

end

 

Didn't the Scene tree use to show the model Hierarchy? Could just drag the weapon to the bone then.

 

GheGhe yea true, But it is disabled since update 3.5, will try out the gun script

Link to comment
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.

 Share

×
×
  • Create New...