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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by IKilledKenny_2 · Jun 23, 2015 at 05:42 PM · collisionmovementrigidbodycollider

How to tag?

Hello Unity3D.I have a question about Tagging?In multiplayer local 4 player,Is is possible to make a character change the tag when fighting another character with a different tag?For example.Im playing with a friend locally and the characters cameras are split screen and i'm player 1 and my character is tagged player but on my screen its makes the opponent tagged as enemy.and on my friends screen he is player 2 and on his screen his character is tagged player and im tagged enemy,meaning on his screen he sees me as the enemy and on my screen i see him as the enemy.Can you make it that when someone plays multiplayer split screen the tags change depending on whos the player?If yes,Can anyone please tell me how?

Comment
Add comment · Show 8
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 Hellium · Jun 23, 2015 at 10:21 PM 0
Share

When you speak about tags, are you referring Unit's tag ? If yes, and if you are on a splitted screen, it's not possible I guess since a gameobject can have only one tag in the entire scene of a same game.

What do you want to do with these tags ?

avatar image IKilledKenny_2 · Jun 23, 2015 at 10:38 PM 0
Share

I need the tags for auto lock on a character.And dang its not possible so i got to find another way

avatar image Hellium · Jun 23, 2015 at 10:44 PM 0
Share

Even if it's not possible with Unity's tag, you could try to make a custom tag as attribute of your players.

Else, you could simply make your auto lock on gameobjects with the same tag as your player except on your player itself (since the other players are necessarily enemies)

avatar image IKilledKenny_2 · Jun 23, 2015 at 10:55 PM 0
Share

Wait how do i make it that i can auto lock on gameobjects with the same tag as my player except on myself? Becuase the last time i used findwithtag it found with both my character and the enemy having the same tag,it tagged myself xD.Also is there another way that i can find an object on the field without using tags or findgameobject named?

avatar image Valnor · Jun 23, 2015 at 11:56 PM 0
Share

why not create a tag controller script that can handle 4 or so tags set as strigs, and then is tested against a call from another script to see if any of the tags in the controller match the tag it's looking for? or you could simply create a second prefab for player, and have the game test if for tags "player1" and "player2" i.e making player 2 camera find player2 tag on the duplicate instantiated prefab?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mark Gossage · Jun 24, 2015 at 04:03 AM

You don't want 'tag' as per the Unity engine term. These are designed not to be changed at runtime (AFAIK). What you really want is a Team. So just build one.

 class Team: MonoBehaviour
 {
   public int team=0;
 }

You can then attach this script to each player & its a just GetComponent() to access which team you are in & build your game rules accordingly.

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 IKilledKenny_2 · Jun 24, 2015 at 06:21 AM 0
Share

Im sorry can you elaborate more on the $$anonymous$$m subject here ?because i really want to get a firm grasp on this

avatar image bardmask · Jun 24, 2015 at 10:37 AM 0
Share

say you start a match with $$anonymous$$m blue (1) and $$anonymous$$m read (2) every player will have the $$anonymous$$m script on them. when you attack an opposing $$anonymous$$m member you get the $$anonymous$$m members component which is the $$anonymous$$m script. and once you have that you check their $$anonymous$$m variable against yours and if they are the enemy $$anonymous$$m then continue with the attack script;

avatar image IKilledKenny_2 · Jun 24, 2015 at 02:59 PM 0
Share

ok i think i understand what your saying.you want me to make 4 copies of the of the same character and make them each have the $$anonymous$$m script but if i select $$anonymous$$m on they become $$anonymous$$mmates and they attack anyone thats not on their $$anonymous$$m?

avatar image Mark Gossage · Jun 26, 2015 at 08:39 AM 0
Share

Basically yes. In Unity, there is not 2 copies of the world, there is only one copy of the world. So in the world you have a character game object with a Team script which says '$$anonymous$$m=1' and you have a second character game object with a Team script which says '$$anonymous$$m=2'. You can write the code such that the two characters can fight each other because they are on different $$anonymous$$ms. But if you changed them to both be '$$anonymous$$m=1' then they could be the same $$anonymous$$m and you can write your game logic accordingly (remove friendly fire etc).

avatar image IKilledKenny_2 · Jun 26, 2015 at 11:14 PM 0
Share

Wouldn't that make take up more megabyte?$$anonymous$$eaning,is the strategy that the professionals use?If so is there anything i do to limit the coding as much as possible?

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

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Stopping my player from moving when hitting a wall. 5 Answers

can not move my enemy with rigidbody 1 Answer

rigidbody It's going up and bounces when is moving 1 Answer

Avoid Player bouncing when colliding with objects 3D 1 Answer

Player-movable rigidbodies w/ collision? 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