Jump to content
Slimwaffle

3rd person and Weapons and multiplayer

Recommended Posts

Hey guys and girls

So in preparation for 4.6 and multiplayer functionality to leadwerks. I have been thinking about my game and how to prep it. I have decided to use the existing FPS script but add a character model and animations for walking crouching running etc. What I want to know is that when it comes to the weapons, is there a way to do this where the weapons are a child of the character? So that way I can keep the existing fps code and just remove the arms from the weapons models and then just position the guns as children of the characters hands or arms.

Are there any examples of something similar being done before?

Also when the multi player stuff is added will there be a function like update world that works for the multiplayer calls?

Share this post


Link to post

Here's the function for the staff I did in this old video. Offsets were trial and error and need changing for each model. It's called in UpdateWorld() That was my only attempt so there's probably a better way.

function Script:AttachWeapon()
	if self.fingerBone == nil then
		self.fingerBone = self.entity:FindChild("Bone R Finger11")
		if self.fingerBone == nil then
			Debug:Error("Finger bone to attach weapon to not found.")
		end
	end
	local fingerPos = self.fingerBone:GetPosition(true)
	local fingerRot = self.entity:GetRotation(true)

	local tscale = self.entity:GetScale()
	local fPos = Transform:Point(0.01 / tscale.x, .02 / tscale.y, .03 / tscale.z, self.fingerBone, nil) --offset

	playerInfo[ourID].weaponEntity:SetPosition(fPos.x, fPos.y, fPos.z, true)
	playerInfo[ourID].weaponEntity:SetRotation(fingerRot.x-23, fingerRot.y, fingerRot.z, true)
end

 

  • Like 1

Share this post


Link to post

Once you know what entity is the hand bone, I would use SetParent to make the weapon as child (and set offset local position) to set its position only once instead of repositioning it in each UpdateWorld call. If you're using LUA then I would suggest to have a public string property to store the name of the hand bone (you could even think to store names as hierarchy tree, for example "Spine/Chest/Right Arm/Hand" and then splitting by "/" to get it if your model has two entities "Hand" instead of "Hand R/Hand L") and one vector3 property to store the offset local position for the weapon (since these values could easily be different for each model).

Share this post


Link to post

For syncing animation, there will be some new functions that save and load the entity animation stacks.

Share this post


Link to post
On 1/3/2019 at 9:13 PM, Admin said:

@ZioRed why does your avatar say "Senior Programmer" above it? 😲

I don't know, it's you the admin lol, I cannot edit my Rank in Edit Profile 😅

  • Like 1

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