Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Gasmask
Nov 30, 2006

Breaking fingers like fractals

SinineSiil posted:

They broke Mouse X/Y events when cursor is visible with last preview and they are still broken. Ugh

I did a little more searching and it looks like the mouse cursor issue I'm having is a known one at least, but oh man. I don't quite understand the specifics, but it's something to do with showing the mouse cursor and input modes, where mouse capture only works when the mouse cursor is hidden from the playercontroller. Someone on the UE forums said they think it might actually be intended behavior, but I hope not, because I have no idea how to even start figuring this out.

E: here's a link to a UE forum thread that touches on this; the posts about the mouse stuff are up near the top of page 20: https://forums.unrealengine.com/showthread.php?94321-Unreal-Engine-4-11-Preview/page20

The Gasmask fucked around with this message at 18:45 on Apr 1, 2016

Adbot
ADBOT LOVES YOU

Sininu
Jan 8, 2014

The Gasmask posted:

I did a little more searching and it looks like the mouse cursor issue I'm having is a known one at least, but oh man. I don't quite understand the specifics, but it's something to do with showing the mouse cursor and input modes, where mouse capture only works when the mouse cursor is hidden from the playercontroller. Someone on the UE forums said they think it might actually be intended behavior, but I hope not, because I have no idea how to even start figuring this out.

E: here's a link to a UE forum thread that touches on this; the posts about the mouse stuff are up near the top of page 20: https://forums.unrealengine.com/showthread.php?94321-Unreal-Engine-4-11-Preview/page20

That forums poster and I have the same name btw :)
It most likely isn't intended actually, I was afraid it would be because I had similar issue before with input modes and Mouse X/Y events and that for some reason turned out to be intended.

The Gasmask
Nov 30, 2006

Breaking fingers like fractals

SinineSiil posted:

That forums poster and I have the same name btw :)
It most likely isn't intended actually, I was afraid it would be because I had similar issue before with input modes and Mouse X/Y events and that for some reason turned out to be intended.

Hah sorry, I didn't even look at the names. I'm gonna stick with 4.10.4 for now I think, I'd much rather be able to continue working on my project than fight the inevitable new bugs - and at least in my case I can make do without the new features for now.

DStecks
Feb 6, 2012

I'm trying to specify sprites based on a file directory address, and it doesn't seem to be working. I'm using .psd files, since they work just fine as Sprites in the Unity inspector, but when I try to access them by their file address, Resource.Load<Sprite>() doesn't find them. I'm positive that I'm entering the directory address correctly.

Fano
Oct 20, 2010

DStecks posted:

I'm trying to specify sprites based on a file directory address, and it doesn't seem to be working. I'm using .psd files, since they work just fine as Sprites in the Unity inspector, but when I try to access them by their file address, Resource.Load<Sprite>() doesn't find them. I'm positive that I'm entering the directory address correctly.

Are your .psd files inside a Resources folder?

cyxx
Oct 1, 2005

Byon!

DStecks posted:

I'm trying to specify sprites based on a file directory address, and it doesn't seem to be working. I'm using .psd files, since they work just fine as Sprites in the Unity inspector, but when I try to access them by their file address, Resource.Load<Sprite>() doesn't find them. I'm positive that I'm entering the directory address correctly.

Fano is right, it needs to be in the Resources folder (or rather a new folder called 'Resources' in the little file browser thing) and you can just call Resource.Load("blahblah.psd");

You can also make directories in there which you can load by Resources.Load("/blahblahfolder/blahblah.psd");

DStecks
Feb 6, 2012

Oh. I did not know that.

EDIT: It doesn't seem to be working. The Resources folder goes in the Assets folder, correct?

EDIT EDIT: looked up the Unity docs, looks like my second error was including the .psd extension. That seems loving odd. Can you not have resource files with the same name but different extensions?

DStecks fucked around with this message at 19:33 on Apr 4, 2016

cyxx
Oct 1, 2005

Byon!

DStecks posted:

EDIT EDIT: looked up the Unity docs, looks like my second error was including the .psd extension. That seems loving odd. Can you not have resource files with the same name but different extensions?

Huh, I never noticed that you don't need the extension for some reason.

But there's an overload where the 2nd parameter is a type so you can probably differentiate it that way if you reallllllly need to?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

DStecks posted:

Can you not have resource files with the same name but different extensions?
That seems weird at first glance, but on thinking about it, it's quite a good idea, in that it means you can switch out your psds for pngs or your mp3s for oggs or whatever without having to modify your code.

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Unreal RTS person here again. Lost inspiration the past couple weeks, but I opened up UE4 and sunk a few more hours into it.

I refactored a lot of how the behavior tree interaction stuff works for my units, and I was able to completely remove Tick from being involved at all in the process (apart from the native behavior tree stuff anyway).

I also fixed how my units would freeze for a few milliseconds if you spammed them with orders. Learned a bit more about GameMode and PlayerState, too.

This is the part where I'd usually post a Youtube link or something, but unfortunately the changes aren't really visible at all so I actually didn't bother this time. Maybe next time.

Sininu
Jan 8, 2014

Love Stole the Day posted:

Unreal RTS person here again. Lost inspiration the past couple weeks, but I opened up UE4 and sunk a few more hours into it.

I refactored a lot of how the behavior tree interaction stuff works for my units, and I was able to completely remove Tick from being involved at all in the process (apart from the native behavior tree stuff anyway).

I also fixed how my units would freeze for a few milliseconds if you spammed them with orders. Learned a bit more about GameMode and PlayerState, too.

This is the part where I'd usually post a Youtube link or something, but unfortunately the changes aren't really visible at all so I actually didn't bother this time. Maybe next time.

Glad to hear you haven't given up!

Stick100
Mar 18, 2003
I did another investigation of CryEngine and their beginners guide.

https://www.youtube.com/watch?v=WC7nSXOiicM

Results:
CryEngine has been patched (although still listed as version 5.0.0) and that has fixed some issues but introduced some others.
Crytech has uploaded assets that were referenced in the beginners guide so it works slightly better now.
It looks like the current version of Crytech is broken on Spline generation (making roads), or can easily be broken.
The beginners guide has some incorrect references due to changes between 3 and 5 (although this is supposed to be a guide for 5).

Crytech looks really really nice and runs very well by default.

I'd still suggest that people stay away (at least compared to UE and Unity), but I think I'll continue to investigate.

mike12345
Jul 14, 2008

"Whether the Earth was created in 7 days, or 7 actual eras, I'm not sure we'll ever be able to answer that. It's one of the great mysteries."





http://makeindiegamesincapetown.com/

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Every dev I've met from South Africa has been cool as gently caress so that checks out.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
When working with the Bullet library, is it necessary to keep cache and memory optimisations in mind, or does the library handle that for you? As far as I can tell the SOP is to allocate all bodies and information relating to them yourself and then pass it to the dynamics world, but for any large-scale physics engine this stuff needs to be allocated in a reasonable way to avoid cache misses and remain performant. Have they overloaded the new operator or something to ensure that this happens or is this up to me as the user of the library?

E: If it's up to me to do this, is there any succint guide to the algorithms they use? I feel like I have to know exactly how they step through the data and how it is structured to know how to organise it during allocation, but I don't have the time to read through the entire source code.

Joda fucked around with this message at 05:59 on Apr 7, 2016

Cory Parsnipson
Nov 15, 2015
Are MVC architectures mutually exclusive with entity component systems? Would it be useful to combine them?

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Cory Parsnipson posted:

Are MVC architectures mutually exclusive with entity component systems? Would it be useful to combine them?

Aren't they solving two different problems, at least at a low level? I'm fairly new to ECS, but the way I understand it it is concerned almost exclusively with the model part of the MVC pattern. At least for low-level draw code, I can imagine it being a pain to have it be performant while also trying to accommodate ECS.

E: In short, I don't see a good reason why a combination should be a bad thing/contrary to their respective purposes.

Joda fucked around with this message at 02:43 on Apr 8, 2016

Cory Parsnipson
Nov 15, 2015
Oh excellent. I was wondering about something like that. I don't really have ECS concepts down yet. I haven't really played around with them before but that is a cool idea to apply them to the models.

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.
In unity, if I want to scale multiple objects at once, I can use the rect tool or the scale tool to manipulate many objects at once as if they were one object. However if I use the scale field when multiple objects are selected in the inspector it scales them each from their own reference, so for instance if I scale them all smaller they do get smaller but they are now spready very far apart. How do I scale multiple objects as if they are one using a numeric field like in the inspector to insure I get a proper scale?

Buffis
Apr 29, 2006

I paid for this
Fallen Rib
The mobile puzzle game I've been making during evenings is basically done now. Just need to do a bit more testing before I nail down a release date and try to score some reviews. Would _love_ if some people could try it out to verify it doesn't crash their phones or whatever.

http://buffix.net for the trailer and teaser page.
Get the beta from:

Android: https://play.google.com/apps/testing/com.buffisgames.buffix

iOS: Through iTunes with a Promo code. Listing a few codes here to grab:
H6T4M746XFPE
A3LYK3XRAKHF
FYF9JEK74RYM
4H36FYYWFXY9
JMXXL993FN96
EM67FTHH6F49
NYJFWFLMNKF

https://fat.gfycat.com/SnarlingPaltryAfricanelephant.webm

Star Warrior X
Jul 14, 2004

Knifegrab posted:

In unity, if I want to scale multiple objects at once, I can use the rect tool or the scale tool to manipulate many objects at once as if they were one object. However if I use the scale field when multiple objects are selected in the inspector it scales them each from their own reference, so for instance if I scale them all smaller they do get smaller but they are now spready very far apart. How do I scale multiple objects as if they are one using a numeric field like in the inspector to insure I get a proper scale?

Make a new empty gameObject, make it the parent of all the other objects you want to scale together, and then change its scale. Note: this will change the position of all of the sub-objects, but it sounds like that's what you want.

The Gasmask
Nov 30, 2006

Breaking fingers like fractals

Buffis posted:

The mobile puzzle game I've been making during evenings is basically done now. Just need to do a bit more testing before I nail down a release date and try to score some reviews. Would _love_ if some people could try it out to verify it doesn't crash their phones or whatever.

I grabbed this code: 4H36FYYWFXY9

Just gave it a run, no crashes or anything on easy for one full game, will give the other modes a go too.

I did find it a little imprecise when moving a piece after it appears - the initial touch can jerk it around unintentionally, which led to misplaced moves when they started stacking high. I'm on an iPhone 5s so it's not the biggest screen, I'll check it out on the iPad next and see if that's why.

Okay, now here's my puzzle game bitching (and don't take this personally) - this is impossible for colorblind people. The groups of colors look almost exactly the same (the shade is way too close), and I'm still not sure if there are multiple colors of the red one? I kept on putting what I thought was 3 in a row, only to realize a good 15 seconds later that the blues or whatever don't match or the green(?) and yellows(??) aren't the same.

I love these kinds of games and it sucks having the majority of the genre cut off due to lovely genes. I'm not really sure if it's even a reasonable fix for you, but there are a few different ways around it. Increasing contrast between the shades of colors is the best - it can be done with postprocess, and tested by looking at the game in greyscale. If the pieces look nearly the same, the contrast needs to be increased (and whatever other tweaking seems appropriate).

You could also do what some of the big name games do (bejeweled is the prime example) and use different shapes. In your case you could put the shapes inside the blocks at a brighter shade of the same color, so it would be easy to see at a glance that a piece has a triangle or a diamond or a circle, etc. This seems like a bit more work than just changing the colors though.

I don't want to end this on a bad note, so other than the colorblind thing (which admittedly kills my ability to play it comfortably), I like the art direction a lot, especially re: the background, and the sound and music design fit it pretty well. I'll be pushing through some more games regardless to get you more feedback.

The Gasmask fucked around with this message at 14:58 on Apr 8, 2016

Buffis
Apr 29, 2006

I paid for this
Fallen Rib
Thanks for the feedback, I appreciate it a lot! Yeah, I should probably add a colorblind mode. Adding shapes inside the blocks is likely the easiest way for me to do it. Also, not that matching vertically is not meant to work, if that could be part of the reason for you.

Colorblindmode will likely be in the first update post initial release. Right now I just want to get this thing released basically, and then I can iterate a bit with less pressure on myself :)

Edit: Do you think adding letters inside the blocks when a colorblind option is set in options be too lazy?
R for Red, P for Pink and so on... Super lazy solution but would be easy to do.

Edit2: Might actually make sense to have this in place before release, since this will obviously lead to at least some bad reviews otherwise. Guess I should start looking at this during the weekend.

Buffis fucked around with this message at 15:15 on Apr 8, 2016

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

Star Warrior X posted:

Make a new empty gameObject, make it the parent of all the other objects you want to scale together, and then change its scale. Note: this will change the position of all of the sub-objects, but it sounds like that's what you want.

Hmmm not ideal but thanks!

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Gif quality isn't the best but I've been working on a particle system for explosions for my RTS:



Higher quality gfycat video

xzzy
Mar 5, 2009

That's a pretty nice explosion.

Particles seem like the sort of thing that should be easy to make, "spawn some sprites here then push them that way and maybe animate them" but man it takes a lot of fussing to get really high quality effects.

I can technically make them in Source and UE4, but they always look like baby's first art project.

Brendan Rodgers
Jun 11, 2014




I'm currently designing a turn based spaceship battle system in Unity and I'd like to know if I'm on the right track, it's the first time I'm decoupling game logic from Unity.

So I have nested coroutines tracking the game state, taking input, and firing off delegate events, instead of the update functions.

Then I have singletons tracking gamestate variables for things that need to see them.

Classes like camera will simply subscribe to delegate events in order to know what to do etc. so it's like event driven and modular I think.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

xzzy posted:

That's a pretty nice explosion.

Particles seem like the sort of thing that should be easy to make, "spawn some sprites here then push them that way and maybe animate them" but man it takes a lot of fussing to get really high quality effects.

I can technically make them in Source and UE4, but they always look like baby's first art project.

Yeah, it took a while. I've found that more simple particles is better than fewer "complex" particles. Theres 16,000 particles in that explosion. That sounds like a lot but everything is done on the GPU and it runs super smooth - the particle update step only involves rendering one 128x128 buffer to another, which is nothing on the GPU. I can get up to about half a million particles before I notice any lag.

For the movement there's four elements: an exponentially decaying initial velocity (the initial explosion), simple directional wind, curl noise (makes it look like the fire/smoke is being chaotically blown around in the air) and a vortex ring (essentially for making that "mushroom cloud" effect).

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.
So I want to create a dynamically laid out area that consists of points (or stars) that are connected by beams (or roads). I want htis done entierly wihtout 3d modelling, but instead using sprites and what not I think, but I am not really sure how to proceed. An equivalent to this would be the elite dangerous galaxy map. I basically want a bunch of points that don't need to have an actual model associated with them, they just need to be some form of sprite. And then I want to connect them with dynmaically lengthed lines (ideally slightly curved).

I am a bit over my head here. Everything I've mocked up in unity thus far has been using 3d models and simple primitives. Is there any obvious way to approach this problem?

I believe I have my startup script running properly to populate the map with these entities I just don't know what entity I need to utilize.

pseudorandom name
May 6, 2007

Buffis posted:

EM67FTHH6F49

Fully functional on a 5s running 9.3.1.

Brendan Rodgers
Jun 11, 2014




Knifegrab posted:

So I want to create a dynamically laid out area that consists of points (or stars) that are connected by beams (or roads). I want htis done entierly wihtout 3d modelling, but instead using sprites and what not I think, but I am not really sure how to proceed. An equivalent to this would be the elite dangerous galaxy map. I basically want a bunch of points that don't need to have an actual model associated with them, they just need to be some form of sprite. And then I want to connect them with dynmaically lengthed lines (ideally slightly curved).

I am a bit over my head here. Everything I've mocked up in unity thus far has been using 3d models and simple primitives. Is there any obvious way to approach this problem?

I believe I have my startup script running properly to populate the map with these entities I just don't know what entity I need to utilize.

Make a bunch of configurable prefabs, write some logic in your startup script for deciding where these entities will be placed and how to configure each one randomly etc, and use object.Instantiate at each one as you go.

I guess you want a procedurally generated galaxy, this may help, it's the actual spaceman maths behind how spiral galaxies are formed and might give you a basis for calculating your star placement, and it has C++ examples of a galaxy renderer. Density Wave Theory

It sounds like you want each of these stars to have a navigable area around it, with these dynamic lines between stars also being navigable and forming roads, you can also use Unity's own prefabs and navmesh/agent system to create this, let's say you make a transparent tile prefab that is the basis of a solar system, marked navigable in the navmesh, then you have a road tile prefab with your line texture placed on it, that is also marked navigable. Then the rest of the galaxy is simply marked as an obstacle and is ignored by your navmesh pathfinding and you can build roads leading to these solar system tiles.

Then instead of in the editor you do this in code slightly randomised and you have random star systems with paths between them, then implement the above mentioned Density Wave Theory and you have a full on procedurally generated galaxy, just don't go overboard with it and keep it simple and abstract.

Brendan Rodgers fucked around with this message at 18:37 on Apr 8, 2016

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

Brendan Rodgers posted:

Make a bunch of configurable prefabs, write some logic in your startup script for deciding where these entities will be placed and how to configure each one randomly etc, and use object.Instantiate at each one as you go.

I guess you want a procedurally generated galaxy, this may help, it's the actual spaceman maths behind how spiral galaxies are formed and might give you a basis for calculating your star placement, and it has C++ examples of a galaxy renderer. Density Wave Theory

It sounds like you want each of these stars to have a navigable area around it, with these dynamic lines between stars also being navigable and forming roads, you can also use Unity's own prefabs and navmesh/agent system to create this, let's say you make a transparent tile prefab that is the basis of a solar system, marked navigable in the navmesh, then you have a road tile prefab with your line texture placed on it, that is also marked navigable. Then the rest of the galaxy is simply marked as an obstacle and is ignored by your navmesh pathfinding and you can build roads leading to these solar system tiles.

Then instead of in the editor you do this in code slightly randomised and you have random star systems with paths between them, then implement the above mentioned Density Wave Theory and you have a full on procedurally generated galaxy, just don't go overboard with it and keep it simple and abstract.

I super appreciate this but unfortunately these assumptions are not correct. This will actually be generated from a file that lists the connections between the stars (maybe nodes is a better descriptor). This will also be in VR roomscale so you can wander about the scene and look at the interconnections but I don't need any travel logic.

That being said thank you for the thorough write up.

The Gasmask
Nov 30, 2006

Breaking fingers like fractals

Buffis posted:

Thanks for the feedback, I appreciate it a lot! Yeah, I should probably add a colorblind mode. Adding shapes inside the blocks is likely the easiest way for me to do it. Also, not that matching vertically is not meant to work, if that could be part of the reason for you.

Colorblindmode will likely be in the first update post initial release. Right now I just want to get this thing released basically, and then I can iterate a bit with less pressure on myself :)

Edit: Do you think adding letters inside the blocks when a colorblind option is set in options be too lazy?
R for Red, P for Pink and so on... Super lazy solution but would be easy to do.

Edit2: Might actually make sense to have this in place before release, since this will obviously lead to at least some bad reviews otherwise. Guess I should start looking at this during the weekend.

Awesome, this is really good to hear! Any kind of differentiation is good, so letters should work fine. It's also unique, I don't think I've seen a game use that solution, so it will help it stand out some more.

I actually figured out about the vertical thing immediately after the first run. I checked the options menu to see if there was some help and caught the text. That definitely was one of my problems, but that's all on me for not paying enough attention!

Brendan Rodgers
Jun 11, 2014




Knifegrab posted:

I super appreciate this but unfortunately these assumptions are not correct. This will actually be generated from a file that lists the connections between the stars (maybe nodes is a better descriptor). This will also be in VR roomscale so you can wander about the scene and look at the interconnections but I don't need any travel logic.

That being said thank you for the thorough write up.

Sorry, I assumed from your descriptions of nodes as "stars" and the comparison to Elite Dangerous. I'm struggling to understand your question then, it would help if you laid out what you wanna do in more detail, maybe another goon could answer in that case.

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

Brendan Rodgers posted:

Sorry, I assumed from your descriptions of nodes as "stars" and the comparison to Elite Dangerous. I'm struggling to understand your question then, it would help if you laid out what you wanna do in more detail, maybe another goon could answer in that case.

I have a list of csv values that describes a linked list.

In the list it says basically

Node A connects to Node B.

Node C connects to Node B.


So now I need to generate a world that shows Node A and Node C connecting to Node B (it is directional).

I want the nodes to be represented by sprites or something, not an actual 3d model, and I want to somehow draw lines connecting the nodes also be non-3d entitites.

THis will be done in 3d not 2d, but ultaimtely from top-down it would look relatively 2d.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
What's the issue that you're having, the actual drawing of the elements, or the laying-out of the graph?

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

Dr. Stab posted:

What's the issue that you're having, the actual drawing of the elements, or the laying-out of the graph?

I... I don't even know what kind of elements to use.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
I've not used unity in a while, but from looking at the API, I'd start by making a Sprite for the nodes, and a LineRenderer for the edges. This won't have directionality, but it should be fine to start with.

Brendan Rodgers posted:

Make a bunch of configurable prefabs, write some logic in your startup script for deciding where these entities will be placed and how to configure each one randomly etc, and use object.Instantiate at each one as you go.

This is basically what you need to do. Arrange the nodes in some regular pattern, or at random, before trying to apply a more sophisticated dynamic layout.

22 Eargesplitten
Oct 10, 2010



22 Eargesplitten posted:

I'm getting a weird error in my Unity project. It's giving me a null reference exception at the bottom line here.

code:
//Up in the variable declarations
private GameObject vaultedObject;

//farther down
   public void TypeChecker(GameObject vaultedIn)
    {
        vaultedObject = vaultedIn;

If I was doing this in java, I would think I would need to make a new object declaration, but Unity doesn't use that. "NullReferenceException: Object reference not set to an instance of an object." It's saying that about vaultedObject specifically.

Thanks for the advice earlier. Eventually, after adding and removing a bunch of things, it told me that the problem was in the next line. It's weird, neither VS nor MonoDevelop said there was a line ending problem. What it ended up being was I used GameObject.Find("vaultedObject") instead of just vaultedObject, which was the problem because there wasn't anything in the scene named vaultedObject. Now I feel dumb, but at least I solved it.

In Unity, if I want to move the camera gradually, should I be using a Lerp? The camera bobs when I land from a jump because the hitbox goes from being half height to full height. I like the effect, but I want it to be more gradual, rather than happening in a single frame. I might get rid of the effect altogether once I've got it more fleshed out, in case it gets annoying.

Adbot
ADBOT LOVES YOU

Inverness
Feb 4, 2009

Fully configurable personal assistant.
Speaking of ECS, it seems to me like the best way to balance usefulness with performance in a game using C# is by treating an entity like you might a program and its libraries:
  • Components get direct references on construction to other components they depend on from the same entity.
  • Components use public properties/fields on the components they depend on.
  • Components can subscribe to events from components they depend on.
  • Components cannot be removed from an entity once they're added. This means you don't need to worry about cleanup code between components on the same entity.

Here's a simple example of a component that moves an actor to another level when touched. It depends on a collider of any type.
C# code:
using System;
using System.Collections;
using Microsoft.Xna.Framework;

namespace Ramp.Simulation
{
    /// <summary>
    ///     A link that, when activated by overlapping, moves the activator to another level.
    /// </summary>
    public class LevelLinkBehavior : Behavior, IActivatable
    {
        private readonly Collider _collider;

        public LevelLinkBehavior()
        {
            GetComponentRequired(out _collider);
            _collider.ActorOverlapBegan += OnActorOverlapBegan;

            TargetName = Actor.GetSpawnArgument<string>("LinkLevel");
            TargetPosition = Actor.GetSpawnArgument<Vector2>("LinkPosition");
        }

        /// <summary>
        ///     Name of the target level.
        /// </summary>
        public string TargetName { get; set; }

        /// <summary>
        ///     Target position to place the actor in.
        /// </summary>
        public Vector2 TargetPosition { get; set; }

        protected virtual void OnActorOverlapBegan(Collider sender, ActorCollisionEventArgs e)
        {
            Activate(e.Other.Actor);
        }

        /// <summary>
        ///     Activate the level link, causing the target to be moved to the destination level and position.
        /// </summary>
        public virtual void Activate(Actor target)
        {
            if (!Enabled || target == Actor || !target.CanChangeLevels || target.IsLevelChanging)
                return;
			
            World.StartCoroutine(target.ChangeLevelCor(TargetName, TargetPosition));
        }
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply