Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:44:41+00:00 2026-06-09T00:44:41+00:00

I have a sandbox world in Unity with various GameObjects that will eventually have

  • 0

I have a sandbox world in Unity with various GameObjects that will eventually have a set of interactions that the player can choose from once they click on this object (best example would be The Sims).

I basically want each object to contain a list of methods which have been assigned from another list of methods. So maybe there is a Tree with the “shake” method, I want to assigned the “shake” method to the Tree’s interaction list but the shake method is defined in another class. I also might have a car which could also have the “shake” method.

I understand that I can have a list of Action.

List<Action> interactions = new List<Action>();

and that this list can be populated with methods but Is this the best solution for what I explained above, and can i somehow have a Enum with all possible interactions which would automatically call a particular method for the particular GameObject?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:44:42+00:00Added an answer on June 9, 2026 at 12:44 am

    I don’t know exactly what you’re trying to achieve and whether it is the best solution, but to me this sounds like a good use for the strategy pattern:

    // This is the 'strategy' in your case
    public interface IInteraction
    {
        void Do();
    }
    
    public class GameObject
    {
        // Here is your list of interactions - you can do whatever you want with it.
        public List<IInteraction> Interactions { get; set; }
    }
    
    // Here is an interaction
    public class Shake : IInteraction
    {
        public void Do()
        {
            ....
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a db dump import script from our production db that we use
I have a factory that is supposed to create objects that inherit from class
I am working on a project that i want to have a plugin-sandbox like
I have a really strong feeling that this question will either be closed or
I have git status reporting numerous files deleted from my sandbox: # deleted: prj1/.classpath
Suppose I have the following dictionary and list: my_dictionary = {1:hello, 2:goodbye, 3:World, sand:box}
I have a Sandbox which contains plenty of items composed of one or more
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
I'm developing this website: http://parkoura.tk/a/sandbox/ I am using an ajax navigation. I have a
We have a non-standard subversion respository that we would like to convert to Git.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.