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 Lysys · Sep 10, 2016 at 08:52 AM · c#randomizationconnecting

Is there a way to connect scripts in a way where they can be assembled like building blocks?

Is there a way to take multiple scripts (probably a lot) and connect them to form sort of a tree? The principle is that there'll be a randomized choice between a few options, and there will be a long line of those, and the next one to run will depend on the outcomes of the ones previous. Another thing I'd like to do is be able to easily add "limbs" to this tree, and rearrange them if I need to. Is there any way to do this? Thanks in advance!

Comment
Add comment · Show 5
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 NoseKills · Sep 10, 2016 at 05:50 PM 0
Share

Yes there is. Based only on this vague verbal explanation i cannot say much more than that though.

avatar image Lysys · Sep 10, 2016 at 08:39 PM 0
Share

I'm kind of a huge noob, so I'm sorry if my explanation doesn't make sense. What I'm trying to do is to make a system of randomization, wherein everything about the character gets randomized, from their appearance to their interests to their environment. The first part would be simple and vague, for example deciding whether the character was rich or poor, or somewhere in between. And then, depending on the result of that, there would be another one. (Let's say they turned out to be rich, and the next one would deter$$anonymous$$e what type of house they lived in) There would be a different set out outcomes for each outcome of the first question, and so on and so forth until there would be a large tree of outcomes. And then, later in development, I'd like to be able to add branches to this tree relatively easily, and move them around in their order without (much) difficulty. Sorry if this is still not enough information.

avatar image metalted · Sep 11, 2016 at 09:50 AM 1
Share

I understand the idea, but as you call yourself "a huge noob", this may be a little out of your reach. Object Oriented Program$$anonymous$$g, Interfaces, Inheritance, Polymorphism etc.. are all subjects you are going to run into. It takes time and study to understand how to apply and make this. Its not impossible dont get me wrong, but the best way to achieve this is to read about it and try it out.

https://unity3d.com/learn/tutorials/topics/scripting

This is a good place to get started i think. And to answer your question: YES!

avatar image SkillBased · Sep 14, 2016 at 03:45 AM 0
Share

This is kind of out of reach for an absolute beginner for the moment. I second what metalted mentioned.

Get the foundations of C# OOP (Object Oriented Program$$anonymous$$g) under your belt. Specifically understand these topics:

Inheritance, Polymorphism, Constructors and perhaps even Generics.

It sounds like a lot of hot garbage when you read that but really there's no reason you can't learn all of that within a few months to a year if you take it step-by-step. It all makes a lot more sense in sequence and builds one concept to the next.

While you might be a ways out to understanding and implementing this code, eventually you might want to check out my approach to combining C# OOP with Unity's Component-based system.

I created a tutorial for this. In this example I lay out enemy class variations that branch out in their differences using inheritance (movement patterns, properties like speed and size, etc). I then connect these different enemy scripts to a "master" class that would be something like:

  Enemy<T> where T : Enemy

Which also creates a gameObject and attaches the enemy script where that "T" in the angled brackets is referenced at instantiation. Your instantiation code will look something like:

 Enemy<Ghost> ghost = new Enemy<Ghost>();

The Ghost class would then expand on the base code (shared stuff) you find in the Enemy class. The inheritance tree for all that would be:

 Enemy : $$anonymous$$onoBehaviour
 
 Ghost : Enemy 


You can then access the ghost's relevant properties, such as its speed, (or whatever else you want) with something like:

 ghost.ScriptComponent.Speed = 5;


This overall approach I'm describing lets you also do everything (and keep track of everything) in code rather than in the Unity Editor. Programmers tend to like to stay in code :)

Here's that tutorial. Just keep in $$anonymous$$d, it will look like PURE nonsense right now. Do not take that to mean that it's difficult to learn. Good luck!

https://www.devu.com/free-videos/freebie-unity-constructing-oop-enemy-classes/

avatar image AnthonyHJ-SAH · Sep 14, 2016 at 09:32 AM 0
Share

While it may be something of a contentious proposition, maybe you need to look outside Unity for a drag & drop scripting language. Depending on your needs, you could even go as simple as Scratch. I think Unreal Engine 4 has something along those lines too, if I'm allowed to mention that particular engine...

0 Replies

· Add your reply
  • Sort: 

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

8 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

An OS design issue: File types associated with their appropriate programs 1 Answer

Is it possible to always make animations play differently? 0 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