Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by ExTheSea · Jun 04, 2012 at 08:10 PM · multiplayerfpscharactersetup

Setting up a Character Question.

Hello Guys.

So I'm making a Multiplayer First Person Shooter.

Currently I have weaponmodels with hands attached to them. My Player is a Sphere for test purposes. I also have a model of a soldier which I didn't used until now.

Because my Game will be Multiplayer I want to set up a player with the weapon in his hands. This way I don't need several models for the local player and the other players.

I could make it so that I import the weaponmodel to the soldier model and then model the soldier around it and also animate them both in one model. This way I had to switch the entire soldiermodel when I just switch weapon. This seems to be a lot of work and will probably cause a lot of problems.

So I want to ask wether there is a better way to set up a character or wether you can improve my thoughts.

I hope the question was easy to understand and I also hope that someone knows an answer.

Every help is much appreciated.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ExTheSea · Jun 05, 2012 at 12:14 PM 0
Share

I had an idea lately:

There is only one soldier model. The weapon gets spawned in at the right position by maybe the help of an empty gameobject. The weaponmodels and the soldier-model get animated at the same time and in one file but then before importing them into unity get seperated.This way I would have the soldiermodel have animations which fit to the animations the weaponmodels have. The only challenge then would be spawning the weapons in the right position. Every time you change the weapon another weaponmodel gets activated and another fitting idle animations gets played in a loop.

Is this an easy way of doint things or will I run into problems real quick.

I'm open for your ideas this is just what came to my today.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by aldonaletto · Jun 05, 2012 at 12:40 PM

The easiest way is to have an empty game object (say, Weapon) childed to the hand bone. All possible weapons are childed to Weapon, each one previously adjusted to the correct position/rotation. Locate the object Weapon at Start and save a reference to it (or drag it to the reference variable at the Inspector). To select a weapon, deactivate all of the Weapon children and activate only the selected one with GameObject.SetActiveRecursively(onOff).
This works fine for compatible weapons, like rifle, machine gun, rocket launcher etc. but may seem weird when switching to a pistol or - even worse - to an axe or sword. In such cases, maybe the whole character should be switched - or at least its mesh (have not tested this).

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ExTheSea · Jun 05, 2012 at 01:07 PM 0
Share

Did you look at my comment under the question. The way you are explaining can probably fit really good to it. When I do it as you said and have like different idle animation for a rifle and a pistol. This way I don't have to change the model each time I switch weapon. I just have to switch the idle animation. Do you think this would work?

avatar image aldonaletto · Jun 05, 2012 at 02:00 PM 1
Share

That's a good idea: have different animations for specific cases - much better than switch the whole mesh. $$anonymous$$aybe you need other animations too - walk, run, fire - but it's much easier to change the animation names in variables, like this:

var weapons: Transform; var anIdle: String; var anWalk: String; var anRun: String; var anFire: String;

function SwitchWeapon(weaponName: String){ // activate the selected weapon, deactivate the others: for (var weapon: Transform in weapons){ weapon.gameObject.SetActiveRecursively(weapon.name == weaponName); } // switch animation set according to weapon: switch (weaponName){ case "Pistol": anIdle = "IdlePistol"; anWalk = "WalkPistol"; anRun = "RunPistol"; anFire = "FirePistol"; break; case "Rifle": case "$$anonymous$$achineGun": case "RocketLauncher": anIdle = "IdleRifle"; anWalk = "WalkRifle"; anRun = "RunRifle"; anFire = "FireRifle"; break; } }

// then use the variables ins$$anonymous$$d of the animation names: ... if (speed < 0.2){ animation.CrossFade(anIdle); } else if (speed < 3.5){ animation.CrossFade(anWalk); } else { animation.CrossFade(anRun); } ...

avatar image ExTheSea · Jun 05, 2012 at 02:04 PM 0
Share

Yes i thought about it and I think I'm gonna do it so that I will animate the soldier and the weapon in one file and then when I'm ready seperate them into different files. This way the soldier has every animation for every possible weapon.

Btw. I have my script to switch weapon and such already done and it works(I use a two weapons system). So implementing the animation stuff won't be that much of a big deal I hope :).

Thaks aldonaletto you were a great help and managed to form out my first idea so far that I'm really confident about using it.

Huge thanks.

avatar image aldonaletto · Jun 05, 2012 at 02:06 PM 0
Share

NOTE: you still can have only one weapon object childed to the appropriate bone.

avatar image ExTheSea · Jun 05, 2012 at 02:12 PM 0
Share

I don't know until now wether I will child it to the bone or maybe have it seperate to the soldier model. I know that when its childed to that bone it will be better for movement but I think it will be more difficult to access it from other script. I will see when I really make it.

PS: With two weapon system I mean you have one weapon on 1 and one on 2 and can replace them by picking another one up.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiplayer FPS movement and animations character 1 Answer

Multiplayer FPS Character Model Question 3 Answers

FPS Character Modelling help, (ie, hands, arms, vs full body, etc) 1 Answer

non-authorative fps, client controlled character 0 Answers

FPS MultiPlayer 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges