Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by CGEworks · Feb 21, 2017 at 12:36 PM · scripting problemscripting beginnerbeginnerscriptingbasicscharacters

How to implement tokenization of game characters?

So I’m a beginner dev working on a turn based dungeon crawler/RPG. At the beginning of each mission, the player will select what characters they want in their party from a roster/pool of available characters (à la X-Com). Not sure if it’s relevant but characters will be generated at runtime.

At the beginning of the project I got some good advice from the forums on how to structure things etc, and one of the bits of advice I got was:

“You'll also want to tokenise the characters, because you'll be referring to them a lot. A naive approach is to simply hold an array of all the characters and pass around indexes to this array. Don't do this. It leads to a nightmare of indexing hell. It also couples everything to the class with the array. Instead pass around tokens that contain the key references you will need.”

While I understand the concept of tokenisation in broad terms, I have no idea how to implement it and my normally strong Google-fu has failed to turn up anything I can really use.

So there’s really two parts to this question:

First: Can someone explain (or point me towards an explanation) the basic principles of how to implement tokenisation in Unity?

Second: Can someone recommend a suitable approach (or point me towards a tutorial) for implementing tokenisation of my characters?

Thanks!

Comment
Add comment
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

1 Reply

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

Answer by gameplay4all · Feb 21, 2017 at 01:04 PM

I guess you could use a Dictionary! It's in the System.Collections.Generic namespace. Instead of an index you can refer to an object in the dictionary with a key which can be a string and thus a token.

Good luck!

-Gameplay4all

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

Question regarding Raycast hitting UI button object instead of gameobject 0 Answers

Beginner Question: How to get normals from a physics raycast using visual scripting? 0 Answers

looking for a way to set an integer to another number based on a condition. 2 Answers

I Have made a movement script for my pacman sprite. But animations keep playing even when there is no input. ans when i drag my sprite around in the scene it keeps trying to return to its original position. 0 Answers

Attacking mulitple targets simultanously 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