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
SlightlyMadman
Jan 14, 2005

So I've gotten to the point with something in Unity that seems so stupid that I must be doing it wrong. My understanding for how to spawn GameObjects programmatically is that you set up a prefab, make it a public property in your script, and drag the prefab into that exposed property in the editor. With now about 30 different walls, floors, and room features, this is becoming unmaintainable. Not only do I have to add a new one each time it's added, but Unity constantly forgets the assignments and makes me reassign everything from scratch.

Can I just create a GameObject from scratch in code, instead of instantiating a prefab, or at the very least pull it by name instead of a public property that's been assigned?

Adbot
ADBOT LOVES YOU

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

SlightlyMadman posted:

So I've gotten to the point with something in Unity that seems so stupid that I must be doing it wrong. My understanding for how to spawn GameObjects programmatically is that you set up a prefab, make it a public property in your script, and drag the prefab into that exposed property in the editor. With now about 30 different walls, floors, and room features, this is becoming unmaintainable. Not only do I have to add a new one each time it's added, but Unity constantly forgets the assignments and makes me reassign everything from scratch.

Can I just create a GameObject from scratch in code, instead of instantiating a prefab, or at the very least pull it by name instead of a public property that's been assigned?
Yes you can create blank GameObjects just with "new GameObject(name)" and adding components yourself, or pull them by name from your Resources folder with "Resources.Load(name)".

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!

SupSuper posted:

Yes you can create blank GameObjects just with "new GameObject(name)" and adding components yourself, or pull them by name from your Resources folder with "Resources.Load(name)".
Also perhaps worth mentioning is that you can have a public array of prefabs so that you don't have to keep loving with the code every time you want to drag in a new prefab. If you prefer code then SupSuper's way is better, but this is another way to make the prefab-dragging a bit less frustrating.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Zizi posted:

Oh, yeah. The Physics system needs rigidbodies. I'm surprised anything worked at all without one.

Collisions will 'work' to varying degrees. Just remember though... if it doesn't have a rigidbody and you move it the whole physx world needs to be rebuilt (super slow).

SlightlyMadman
Jan 14, 2005

roomforthetuna posted:

Also perhaps worth mentioning is that you can have a public array of prefabs so that you don't have to keep loving with the code every time you want to drag in a new prefab. If you prefer code then SupSuper's way is better, but this is another way to make the prefab-dragging a bit less frustrating.

Thanks! I replaced them all with Resource.Load and it all works great! This brings me to my next question: whenever I create a class that needs access to the prefabs, I have to pass them all in when I create the object. Now that I know I can load them up in code, I could theoretically load them up as needed, right? Is there a performance drawback to calling Resource.Load, or is it smart enough to keep previously loaded resources in memory and pass over the same reference?

Maybe I should just make a static ResourceHandler class and lazy-load them all there in static properties, so I can just call ResourseHandler.WhateverPrefab as needed?

xgalaxy
Jan 27, 2004
i write code

SlightlyMadman posted:

Thanks! I replaced them all with Resource.Load and it all works great! This brings me to my next question: whenever I create a class that needs access to the prefabs, I have to pass them all in when I create the object. Now that I know I can load them up in code, I could theoretically load them up as needed, right? Is there a performance drawback to calling Resource.Load, or is it smart enough to keep previously loaded resources in memory and pass over the same reference?

Maybe I should just make a static ResourceHandler class and lazy-load them all there in static properties, so I can just call ResourseHandler.WhateverPrefab as needed?

Multiple calls to Resources.Load to the same resource should be fast, because it will keep the resource in memory - unless you told it to unload that resource or all resources. If you are on mobile it would be smart to manage this a bit so your memory usage doesn't balloon.

Keep in mind Resources.Load is synchronous so it will temporarily trash performance if loading a large resource for the first time. There are different ways to mitigate that if you find it becomes a problem.

xgalaxy fucked around with this message at 14:50 on Oct 17, 2013

Hughlander
May 11, 2005

OneEightHundred posted:

What fails to compile is things like indexes and quantities that expect unsigned numbers. While using signed ints in the case you mentioned may give you a more sensible number, what it doesn't do is give you one that's valid to pass to things that can't sanely process a negative number. Most things with a lower bound have an upper bound as well, so if you're using signed, not only do you have to check for the case where y>x, you also have to check for cases where y is negative and will exceed the upper bound.

The D3 gold duping thing might have been caused by a botched conversion, but my question then would be what they're using signed numbers for in the trade system in the first place. Unless you're playing Eve, negative numbers are not valid as any quantity or currency numbers, so why use them? Why risk a dupe exploit if you don't meticulously check that (quantityToDraw < quantityOwned) is also followed by (quantityToDraw > 0) every time?

My general view on it is that most integers numbers not directly related to game physics tend to be invalid below zero anyway, because they're for things like quantities and indexes, and most of the difficulty comes from mismatches and conversion rather than arithmetic underflow/overflow. Using signed/unsigned consistently with their purposes (which minimizes conversions) and handling subtraction and casts with caution is easier than checking for negative numbers everywhere.

While I don't take much of a stand against signed/unsigned for this, the one thing I champion over and over is never treat your experience or currency as a native type. Just about every game I've ever been on that has done this has had crippling flaws with it. Instead of having:

code:
    if (current_money > money_owed) {
        current_money =- money_owed;
    }
littered throughout your source code wrap it in a class and keep it all in one place:
code:
class Money {
public:
    explicit Money(int amount);
    bool credit(Money amount);
    bool debit(Money amount);
private:
    // Could be signed, could be unsigned, could be 64 bit, could be BigInt, you can swap it later and you won't care!
    Money_t amount;
};
The number of times we had to swap the base type of money/xp per game approaches 1, wrap it all up and save yourself the future heartache. Nowadays I'd probably even have credit/debit throw() in case of under/overflow.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
2D Toolkit is half off today on the Unity asset store. I know 4.3 is going to add a ton of 2D features, but until that's released and polished a bit, this is the best 2D solution so far that I've used.

https://www.assetstore.unity3d.com/#/content/908

superh
Oct 10, 2007

Touching every treasure

poemdexter posted:

2D Toolkit is half off today on the Unity asset store. I know 4.3 is going to add a ton of 2D features, but until that's released and polished a bit, this is the best 2D solution so far that I've used.

https://www.assetstore.unity3d.com/#/content/908

I can vouch for 2D Toolkit too, it's got some real slick dicing / texture packing features that work well. The workflow is a bit rough when you're used to something like Flash but it's the best that's out there now.

e: I'm using it at this very moment too! In a legacy publish-to-Flash project. :smith:

xgalaxy
Jan 27, 2004
i write code
2D Toolkit also built in support for things like tilemaps, a feature not in Unity2D.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch

xgalaxy posted:

Multiple calls to Resources.Load to the same resource should be fast, because it will keep the resource in memory - unless you told it to unload that resource or all resources. If you are on mobile it would be smart to manage this a bit so your memory usage doesn't balloon.

Keep in mind Resources.Load is synchronous so it will temporarily trash performance if loading a large resource for the first time. There are different ways to mitigate that if you find it becomes a problem.

So what's the general rule for this? I've pooled all of my resources in Futile by creating what I know I'll need ahead of time and then increasing that pool dynamically but I guess with Resource.Load it's pretty much the same thing?

superh
Oct 10, 2007

Touching every treasure
Here's a dumb Unity question -

I set up a bunch of variables I can edit at runtime on a prefab, which I adjust as needed then hand copy back into my code.

How come some of my prefabs automatically pick up the changes to the source while others never do? Some instances make me remove and re-add the source script component before they update.

I made both of these prefabs using the same steps today, I didn't do anything different that I know of, and I've seen this before but never figured out a solution. Is the answer "because Unity" or "because you need to set x"?


e: Is it because I was accidentally setting custom values on the original prefab in the library (instead of my instanced copy), and this overrides source changes? nooope

Maybe it's the reverse? Maybe it only "keeps" when I accidentally do my editing on the original prefab in the library?

superh fucked around with this message at 18:54 on Oct 17, 2013

devilmouse
Mar 26, 2004

It's just like real life.
I mentioned we were doing this a few weeks ago, but we finally got around to doing a writeup on and releasing our remote debug console for Unity. Using a debug console on mobile devices is awful, so we wrote a slim webserver which runs on the target device and allows you to connect to it with a web browser and use the console from there.

The blog post talking about the what/why is here: http://blog.proletariat.com/post/64309443617/the-cudlr-that-which-cuddles-at-midnight

The github repo with the how is here: https://github.com/proletariatgames/CUDLR

We'll have it up on the Asset Store for free whenever it gets approved for extra-laziness, but in the mean time, if you do any mobile development in Unity and don't like stabbing yourself in the eye, you should check it out. It doesn't work on PC/Mac/consoles yet, but that'll happen either when someone forks it and does it for us or whenever we get around to doing PC/Mac/console builds and have to.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

superh posted:

Here's a dumb Unity question -

I set up a bunch of variables I can edit at runtime on a prefab, which I adjust as needed then hand copy back into my code.

How come some of my prefabs automatically pick up the changes to the source while others never do? Some instances make me remove and re-add the source script component before they update.

I made both of these prefabs using the same steps today, I didn't do anything different that I know of, and I've seen this before but never figured out a solution. Is the answer "because Unity" or "because you need to set x"?


e: Is it because I was accidentally setting custom values on the original prefab in the library (instead of my instanced copy), and this overrides source changes? nooope

Maybe it's the reverse? Maybe it only "keeps" when I accidentally do my editing on the original prefab in the library?
From my experience:

- If you're adding/removing public vars, prefab instances in the editor will eventually pick up on it. At most they will figure it out once you try to run it and get a compiler error.

- If you're changing the initialized value of public vars (eg. change "public int x = 5;" to "public int x = 3;"), prefab instances in the editor rarely pick up on it. This seems to be because as soon as they have a value it will stick, even if you left it at default (new prefab instances will use your new value though). Aside from manually resetting your instances, changing the var type or visibility in the code might force Unity to reset them, but I wouldn't rely on it, as "expecting your prefab instance to have a value and then finding out it has another" is a common headache.

Basically since prefab instances can have their own unique values, there's no guarantee that modifying the original prefab in the library or code will properly spread to all existing prefab instances. My advice is don't go instantiating your prefabs all over until you have the defaults down, and tread carefully in changing prefab instances VS original prefab.

superh
Oct 10, 2007

Touching every treasure
Makes sense (in as much as "never trust it" can make sense!) and it's all good for me - my prefabs are instanced at runtime from the library so as long as the original is right the instances should be.

The game I'm working on is a fighting game so I notice pretty quickly if all my attack timings are off when I rebuild.

Thanks a lot!

Bastard
Jul 13, 2001

We are each responsible for our own destiny.
gently caress me, I just bought 2D toolkit 2 days ago for the full price :(

Anyway, I pretty much fell in love with Unity3D/2D toolkit after I saw a friend mess around with it, so I'm starting to learn it right now, but I got some questions:

1) What the editor of choice, and are there any other good editors besides MonoDevelop? I'm pretty much hooked on Sublime for everyday development, but so far I haven't been able to find any good Unity/2D Toolkit code completion plugins for Sublime.

2) Any good articles on common workflows, setups, patterns, pitfalls, coding conventions etc?

3) What files and dirs do I need to track in version control, and which ones can I safely ignore?

xzzy
Mar 5, 2009

Bastard posted:

gently caress me, I just bought 2D toolkit 2 days ago for the full price :(

It's the law of the internet, a goon must purchase something at full price before it can be put on sale.

TJChap2840
Sep 24, 2009

poemdexter posted:

2D Toolkit is half off today on the Unity asset store. I know 4.3 is going to add a ton of 2D features, but until that's released and polished a bit, this is the best 2D solution so far that I've used.

https://www.assetstore.unity3d.com/#/content/908

I think this was posted earlier but I don't recall.

Think 2DToolkit will be worth it once Unity2D is released?

Zizi
Jan 7, 2010

TJChap2840 posted:

I think this was posted earlier but I don't recall.

Think 2DToolkit will be worth it once Unity2D is released?

Yes. Reports are that thee's a bunch of useful stuff in Unity2D that'll be behind the paywall (like atlasing), and tk2D supports tilemaps really well, which Unity apparently won't do at all.

SuicideSnowman
Jul 26, 2003

TJChap2840 posted:

I think this was posted earlier but I don't recall.

Think 2DToolkit will be worth it once Unity2D is released?

Yep as mentioned above there will be features that will be pro only. You won't ever have to worry about that with 2DTK. Also the developer plans on taking advantage of all the stuff that they're implementing with Unity2D like the physics.

Bocom
Apr 3, 2009

No alibi
No justice
No dream
No hope
Has anyone used DF-GUI? It seems to be pretty similar to NGUI but slightly cheaper.

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna
So once again I have a bit of a physics problem. I recently switched my movement to use CharacterController.Move() instead applying velocity to a gameObject. That fixed any problems of objects climbing over each other, but now my knockback is a bit problematic. I can apply knockback to the character controller, but they don't bounce off of objects like with normal collider physics. Turning off the character controller just makes the player that got knocked back go through any level objects. Can I have a character controller ACT like a normal box collider, or do I actively have to destroy the character controller, apply a collider, apply knockback, delete the collider and reapply a character controller? That sounds a little... workaround.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Chunderstorm posted:

So once again I have a bit of a physics problem. I recently switched my movement to use CharacterController.Move() instead applying velocity to a gameObject. That fixed any problems of objects climbing over each other, but now my knockback is a bit problematic. I can apply knockback to the character controller, but they don't bounce off of objects like with normal collider physics. Turning off the character controller just makes the player that got knocked back go through any level objects. Can I have a character controller ACT like a normal box collider, or do I actively have to destroy the character controller, apply a collider, apply knockback, delete the collider and reapply a character controller? That sounds a little... workaround.

How did going from velocity against a rigidbody to CharacterController.Move() change objects climbing over each other? Did you try rigidbody.AddForce() before swapping to CharacterController? Are you using CharacterController + rigidbody? How are you applying the knockback? Is the player supposed to bounce off an object? Are you expecting the physics engine to do the bounce for you because Move() is constrained by collisions meaning you'll get a dead stop. Do you have your code somewhere because there seems to be a ton of missing info to diagnose.

CharacterController vs. Rigidbody + Collider are pretty drastically different so you might have made the switch and missed something or have the expectation that they'd work the same.

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

poemdexter posted:

How did going from velocity against a rigidbody to CharacterController.Move() change objects climbing over each other? Did you try rigidbody.AddForce() before swapping to CharacterController? Are you using CharacterController + rigidbody? How are you applying the knockback? Is the player supposed to bounce off an object? Are you expecting the physics engine to do the bounce for you because Move() is constrained by collisions meaning you'll get a dead stop. Do you have your code somewhere because there seems to be a ton of missing info to diagnose.

CharacterController vs. Rigidbody + Collider are pretty drastically different so you might have made the switch and missed something or have the expectation that they'd work the same.


Sorry, I'll elaborate. Objects were climbing over each other when they were colliding, which the character controller objects handle natively with their step offset, so I switched to the character controller:

code:
keyWasPressedThisFrame = false; // frame has just started
desiredDirection = Vector2.zero; // don't move the player unless they're trying to
		
// add vectors to desiredDirection based on user input
if (move_Up)
{
	desiredDirection += verticalVector;
	keyWasPressedThisFrame = true;
}

if (move_Down)
{
	desiredDirection -= verticalVector;
	keyWasPressedThisFrame = true;		}

if (move_Left)
{
	desiredDirection -= horizontalVector;
	keyWasPressedThisFrame = true;
}

if (move_Right)
{
	desiredDirection += horizontalVector;
	keyWasPressedThisFrame = true;
}

// normalize sets vector magnitude to 1	
if (desiredDirection != Vector2.zero)
{
	desiredDirection.Normalize();
}

// converting XY to XZ movement axes
myDirectionRight.x = gameObject.transform.right.x;
myDirectionRight.y = gameObject.transform.right.z;

myDirectionForward.x = gameObject.transform.forward.x;
myDirectionForward.y = gameObject.transform.forward.z;

newDirection = desiredDirection.x * myDirectionRight.normalized;
newDirection += desiredDirection.y * myDirectionForward.normalized;

// add acceleration and drag
previousVelocity += (newDirection * acceleration * Time.deltaTime);
previousVelocity *= drag;

// set speed limit
if (previousVelocity.magnitude > movementSpeed)
{
	previousVelocity.Normalize(); // set velocity to 1
	previousVelocity *= movementSpeed; // multiply by movementSpeed, setting current speed to maximum
}
	
// actual movement
Vector3 finalDirection = new Vector3(previousVelocity.x, 0, previousVelocity.y);
finalDirection.y -= gravity;
charController.Move(finalDirection);
Where I have charController.Move(finalDirection), I had:
code:
this.gameObject.rigidbody.AddForce(finalDirection, ForceMode.Impulse);
Which is what I'm using for my knockback script, which detects an opposing player's attack in OnTriggerEnter:
code:
if (other.gameObject.tag == "monsterAttack")
{
	if (!isCurrentlyStunned && !shielding)
	{
		// we have a hit
		isCurrentlyStunned = true;
		
		// find attacking player's relative position, create direction out of it
		GameObject monsterObj = GameObject.FindGameObjectWithTag("monster");
		Vector3 monsterPos = monsterObj.transform.position;
		Vector3 heroPos = this.gameObject.transform.position;
		this.gameObject.rigidbody.velocity = Vector3.zero;

		knockbackDirection = monsterPos - heroPos;
		knockbackDirection.Normalize();
		knockbackDirection *= -30;
		knockbackDirection = new Vector3(knockbackDirection.x, 0, knockbackDirection.z);
		charController.enabled = false;
		this.gameObject.rigidbody.AddForce(knockbackDirection, ForceMode.Impulse);
	}
}
I wanted to use this instead of CharacterController.Move() because I wanted the player getting hit to bounce off of level objects, which CharacterController.Move() doesn't allow by itself. It just keeps trying to move the stunned/knocked back player into the object. When I tried this, the Character Controller physics object wouldn't allow it, but I can't disable it because then the stunned player goes straight through level objects.

I hope that's enough info. Thanks for replying so fast.

Chunderstorm fucked around with this message at 19:51 on Oct 19, 2013

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Chunderstorm posted:

Which is what I'm using for my knockback script, which detects an opposing player's attack in OnTriggerEnter:

(code)

I wanted to use this instead of CharacterController.Move() because I wanted the player getting hit to bounce off of level objects, which CharacterController.Move() doesn't allow by itself. (1)It just keeps trying to move the stunned/knocked back player into the object. When I tried (2)this, the Character Controller physics object wouldn't allow (3)it, but I can't disable (4)it because then the stunned player goes straight through level objects.

(1) What is "it"?
(2) When you tried OnTriggerEnter with CharacterController?
(3) Wouldn't trigger the event?
(4) Disable what?

If I'm parsing correctly, it seems OnTriggerEnter might not be firing for CharacterController. Try replacing the OnTriggerEnter with OnControllerColliderHit.

http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

poemdexter posted:

(1) What is "it"?
(2) When you tried OnTriggerEnter with CharacterController?
(3) Wouldn't trigger the event?
(4) Disable what?

If I'm parsing correctly, it seems OnTriggerEnter might not be firing for CharacterController. Try replacing the OnTriggerEnter with OnControllerColliderHit.

http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html

I think we're on two different pages here.

As far as (1), The CharacterController.Move() function. When I use it as knockback, it moves the Character correctly, but when it a collider, it doesn't bounce off. Using Rigidbody.ApplyForce() WITHOUT a Character Controller does this, since I'm no longer actively moving the object. I want to mimic this kind of behavior with a character controller. Is there an easy way to do that, or am I better off going back to rigidbody+box collider, and finding a different way to compensate for objects "climbing" over each other?

OnTriggerEnter() is working totally fine, I showed that bit of code because you asked how I was applying my knockback.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Chunderstorm posted:

I think we're on two different pages here.

As far as (1), The CharacterController.Move() function. When I use it as knockback, it moves the Character correctly, but when it a collider, it doesn't bounce off. Using Rigidbody.ApplyForce() WITHOUT a Character Controller does this, since I'm no longer actively moving the object. I want to mimic this kind of behavior with a character controller. Is there an easy way to do that, or am I better off going back to rigidbody+box collider, and finding a different way to compensate for objects "climbing" over each other?

OnTriggerEnter() is working totally fine, I showed that bit of code because you asked how I was applying my knockback.

Can you describe the "objects climb over each other" situation? Is it player and mobs rolling over each other? Is it mobs rolling over mobs?

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

poemdexter posted:

Can you describe the "objects climb over each other" situation? Is it player and mobs rolling over each other? Is it mobs rolling over mobs?

Players over each other, and over other objects with colliders.

This is how they start out:


Then I move the monster into the other warrior:


I could just lock their vertical positions but I want them to be able to go up ramps.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Chunderstorm posted:

Players over each other, and over other objects with colliders.

This is how they start out:


Then I move the monster into the other warrior:


I could just lock their vertical positions but I want them to be able to go up ramps.

lock their vertical positions during OnCollisionStay or OnTriggerStay whichever you might need.

Obsurveyor
Jan 10, 2003

Sunday Stupidity:

Spend an embarrassing amount of time debugging a shader that is supposed to use a sphere as a cutaway for another object and learn that, in fact, the magnitude of [0.5, 0.0, 0.0, 1.0] is not 0.5.
:suicide:

At least my goal of the weekend to better understand vertex/fragment shaders is achieved now.

Sylink
Apr 17, 2004

Is there a good 2D game engine available that is cross platform and not XNA? I don't want to build my own engine through SDL.

Any language is fine, but C++ preferred. Really just prototyping something here but if it can be used for a full fledged game then all the better.

Cheston
Jul 17, 2012

(he's got a good thing going)

Sylink posted:

Is there a good 2D game engine available that is cross platform and not XNA? I don't want to build my own engine through SDL.

Any language is fine, but C++ preferred. Really just prototyping something here but if it can be used for a full fledged game then all the better.

Unity with 2D Toolkit using C# is the closest I've gotten to what you described. Check waaaaay up this page or the page before it for some more info.

Sylink
Apr 17, 2004

Looks interesting, has anyone ever messed with Angel 2D?

xgalaxy
Jan 27, 2004
i write code

Sylink posted:

Is there a good 2D game engine available that is cross platform and not XNA? I don't want to build my own engine through SDL.

Any language is fine, but C++ preferred. Really just prototyping something here but if it can be used for a full fledged game then all the better.

https://github.com/GarageGames/Torque2D

It's has its flaws and it is a huge code base. It uses TorqueScript - which is slow. But it wouldn't be terribly difficult to shoehorn lua as a replacement or ignore the scripting part of it altogether.

There are probably simpler engines though.
SDL/SFLM is a library - which you said you don't want. Torque is all the way at the other end of the spectrum. And XNA would be somewhere in the middle -as far as code size, flexibility, complexity, etc.

Hughlander
May 11, 2005

Sylink posted:

Is there a good 2D game engine available that is cross platform and not XNA? I don't want to build my own engine through SDL.

Any language is fine, but C++ preferred. Really just prototyping something here but if it can be used for a full fledged game then all the better.

Across what platforms?

Cocos2d-x is probably the #1 for iOS/Android compat. All C++ other than platform specific initialization.

Sylink
Apr 17, 2004

Phones are nice, I really just wanted something OS neutral for the most part and not a product of Microsoft so that I don't get stuck on Windows on the off-chance I want to run it on something else. Torque looks cool and so does cocos, going to check these out. Thanks guys!

G-Prime
Apr 30, 2003

Baby, when it's love,
if it's not rough it isn't fun.

Sylink posted:

Phones are nice, I really just wanted something OS neutral for the most part and not a product of Microsoft so that I don't get stuck on Windows on the off-chance I want to run it on something else. Torque looks cool and so does cocos, going to check these out. Thanks guys!

MonoGame is an open-source, cross-platform replacement for XNA, and is drat near drop-in compatible, from what I've read.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
^^^^ MonoGame is indeed very cool if you wanna go the C# route.

Sylink posted:

Is there a good 2D game engine available that is cross platform and not XNA? I don't want to build my own engine through SDL.

Any language is fine, but C++ preferred. Really just prototyping something here but if it can be used for a full fledged game then all the better.

If you don't care about language and you want it to run on anything, Java's got some pretty good 2D engines without a ton of cruft, like libgdx or slick2d (both built on lwjgl)

C++ has a poo poo-ton of engines though if that's really what you're looking for, I wouldn't even know where to start. Take some time to google around and compare before you get married to anything. Torque, Ogre, Allegro, etc.

Although when it comes to 2D you don't even need a huge engine anyways. Just some basic graphics libraries to get you going and you can write the rest yourself without much hassle, so things like SDL or SFML.

After that you just need to write a sprite/entity object, some collision detection, and input, and you've got your own game engine. 2D's pretty simple compared to 3D. Then its your own and you can customize as necessary. For that matter you could just bind to openGL and go from there.

If you're just prototyping then OTOH you may not want to take the time for that, but OTOH it'll mean you're freer to try out whatever you want, and you won't have to spend time learning an API and formatting things as the API expects.

Zaphod42 fucked around with this message at 22:19 on Oct 23, 2013

xgalaxy
Jan 27, 2004
i write code
I'm trying to get NGUI and Futile to play nice together but I can't figure out how to setup the cameras correctly.

What I tried doing was this:
- Create a Futile layer at 10
- Create an NGUI layer at 11
- Have all of my NGUI's elements placed on the NGUI layer.
- Set Futile's camera culling mask to the futile layer
- Set Futile's camera clear flags to depth
- Set NGUI's camera culling mask to the ngui layer
- Set Futile's stage.layer to the futile layer.


This sort of works. Both NGUI and Futile will render, but Futile stuff appears above NGUI stuff.

Anyone gotten this to work?

Adbot
ADBOT LOVES YOU

xgalaxy
Jan 27, 2004
i write code
Hmm. Okay I 'think' its working.

I changed Futile camera clear flags to solid color instead (since it renders first it will need to clear the screen).
I changed NGUI camera clear flags to depth
I change Futile camera depth to 0 and NGUI camera depth to 1.

Now NGUI is rendering in front of Futile

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