yes and yes.
Whats the best way of moving them beside translate?
Pretty sure you'd add a 2d rigidbody and set the velocity to your desired direction of movement.
Thanks, works now :D
rigidbody2D.MovePosition() works nicely as well if you want a nicer feel to your movement. Modifying velocity tends to make it feel very floaty, which usually feels sluggish and annoying to use.
[QUOTE=BackwardSpy;45658870]rigidbody2D.MovePosition() works nicely as well if you want a nicer feel to your movement. Modifying velocity tends to make it feel very floaty, which usually feels sluggish and annoying to use.[/QUOTE]
I run my own player movement and plug the velocity into the rigid body directly, seems pretty solid to me. I only do it that way so I can get box2D to handle collisions. I'd much rather have a way to sweep a 2d box through the world like the 3D version has.
[QUOTE=layla;45659915]I run my own player movement and plug the velocity into the rigid body directly, seems pretty solid to me. I only do it that way so I can get box2D to handle collisions. I'd much rather have a way to sweep a 2d box through the world like the 3D version has.[/QUOTE]
You can do that now - they added it in one of the recent updates. MovePosition sweeps the movement you've given it in order to resolve collisions, and if you want to sweep manually you can use the methods in Physics2D, such as BoxCast* and CircleCast*. I haven't used that last set yet (MovePosition has been fine for my needs so far) but I'd assume they work fine.
Woah, how did I miss that! BoxCast is a very useful thing to have.
[QUOTE=layla;45660211]Woah, how did I miss that! BoxCast is a very useful thing to have.[/QUOTE]
Only reason I know about it is because the update came out literally the same day I was looking for a way to do it! :v:
How would you know the difference between music and sound?
Aren't you using Audio Source when you play some music or sound from the player or environment?
[QUOTE=BoowmanTech;45664472]How would you know the difference between music and sound?
Aren't you using Audio Source when you play some music or sound from the player or environment?[/QUOTE]
Internally, Unity does not differentiate between music and sound effects. They are one and the same.
[QUOTE=KillaMaaki;45664529]Internally, Unity does not differentiate between music and sound effects. They are one and the same.[/QUOTE]
That's why I was wondering how it would be done.
Would you loop through all audio sources with specific names,tag...?
Depends on what you need to do. What is it you are trying to accomplish?
Man I wish Unity Pro wasn't so expensive. I really want to create games with shadows and have access to all of the pro features...
[editline]11th August 2014[/editline]
[QUOTE=KillaMaaki;45664622]Depends on what you need to do. What is it you are trying to accomplish?[/QUOTE]
How did you get so good at Unity? I'm looking to learn how to use it better.
If you ever want to add social features to your game just jfuiajuwaeifjia DON'T. Kill that idea right now.
[QUOTE=womayhem;45664766]Man I wish Unity Pro wasn't so expensive. I really want to create games with shadows and have access to all of the pro features...
[editline]11th August 2014[/editline]
How did you get so good at Unity? I'm looking to learn how to use it better.[/QUOTE]
Mostly, just spending a long time working with Unity and actively seeking out new C# concepts.
My earlier Unity games actually were quite terrible and noobish.
[editline]11th August 2014[/editline]
[QUOTE=AtomiCal;45665018]If you ever want to add social features to your game just jfuiajuwaeifjia DON'T. Kill that idea right now.[/QUOTE]
Depends on the game. If it's a multiplayer game, social features can be vital for keeping a player engaged longer. For instance, adding a clan system can potentially increase player retention, as game clans tend to have rules about how often players are required to participate, hold events, etc and that will naturally keep a player coming back.
[QUOTE=KillaMaaki;45665056]
Depends on the game. If it's a multiplayer game, social features can be vital for keeping a player engaged longer. For instance, adding a clan system can potentially increase player retention, as game clans tend to have rules about how often players are required to participate, hold events, etc and that will naturally keep a player coming back.[/QUOTE]
I'm more thinking about GameCenter/GameCircle/Google Play on mobile devices. They are a pain to implement.
[QUOTE=KillaMaaki;45664622]Depends on what you need to do. What is it you are trying to accomplish?[/QUOTE]
Basically I haven't looked around on Google for an answer to my question because I don't want to do it right now. I just posted here out of curiosity, basically in my game I will have a song playing all the time and I will also have sounds that are emitted by the character when he jumps,dies, etc.
What I want to do is stop the all the music in game when I press a button and all the sound when I press a button.
[QUOTE=LuaChobo;45665331]If you really want to get it and have a job but dont want to drop the full amount just get the subscription license,[/QUOTE]
Except the subscription is binding to at least 12 months.
[QUOTE=LuaChobo;45665331]it will automatically upgrade to unity 5 for free when its out whereas the one time payment license wont.[/QUOTE]
I'm pretty sure the one time payment license gives you a free upgrade to 5 too.
As far as I understand it, if you buy a Unity license right now you are preordering Unity 5, and you get 4.x in the meantime.
[editline]12th August 2014[/editline]
[QUOTE=http://unity3d.com/unity/faq]
As of March 18 only Unity Pro 5.X base licenses and deployment add-ons will be available for pre-order in the Online Store.
New customers can pre-order Unity Pro 5.0 for $1500 and immediately get Unity Pro 4.X for immediate use.
[/QUOTE]
Holy dick-shit, layla actually got a position?
Jeez, I gotta work harder on my prototype >.>
That makes me sad, yet happy at the same time.
Good on you Layla, wish you hadn't removed me from your friends :wink:.
That's the thing about Garry, if he says something he'll probably go through with it.
Nevertheless; holy shit.
layla was hired to work on Garry's Mod Source2 obviously.
Doesn't surprise me at all, garry would be a fool not to hire such a talent.
Congratulations Layla, you deserve it! :)
Speaking of working harder on my prototype...
[video=youtube;W8jtl0loUYg]http://www.youtube.com/watch?v=W8jtl0loUYg[/video]
I've got sentry turrets working now.
I ended up having to refactor a ton of my damage dealing and scorekeeping code to get this working.
Sentry turrets are controlled by a state machine with only two states: Scan, and Attack.
- While in Scan, sentry turrets query an octree for nearby player positions. Then that list is pruned via a number of criteria (target is not on my team, target is not outside my field of view, line of sight test to target passes, etc). If there are targets available, they are then sorted by distance, the closest one picked, and the sentry transitions to Attack state.
- While in Attack, sentry turrets will unload bullets on their target. If the target is ever null, outside the sentry's field of view, or line of sight test to target fails, the sentry will transition back to the Scan state.
The next thing I'll add is allowing sentry turrets to take damage and explode. Otherwise, they're just about finished.
(also my sound designer made some shield sounds, so now when shields are depleted you get a warning beep, or when shields are recharging it plays a powering up noise)
EDIT: And congratulations on being accepted! From what I hear, Facepunch is a pretty damn cool place to work.
I also learned a new trick for octrees which I've used for the octree code used by my sentries (for me anyway - I get the feeling that some people here already know this technique >.>). Basically, given an octree node with children, you can find which child node a given point is inside of without checking against the child bounds.
Since Octrees are hard to illustrate, I'll do so with a quadtree instead (same basic idea)
The index of each child node is given two bits. The first bit is set for the X direction, the second bit is set for the Y direction. Like so:
[IMG]http://i.imgur.com/QQv2yfo.png[/IMG]
Given a point, and the center point of the parent node, you can calculate which child contains the point by setting each bit as such:
1.) Set the first bit to 1 if the point's X component is greater than the center's X component
2.) Set the second bit to 1 if the point's Y component is greater than the center's Y component.
That works out to something like this in code:
[code]
int idx = 0;
if( point.x >= center.x ) idx |= 2;
if( point.y >= center.y ) idx |= 1;
return children[ idx ];
[/code]
So comparing against child bounding boxes would be, at worst, 16 comparisons (or at best 4 comparisons). Whereas this technique is only 2 comparisons in every situation.
Extending to an octree is easy enough - add a third bit for the Z direction, and another comparison.
Just kind of a neat trick I think.
EDIT: The funny thing is that, if you don't check to see if the point is inside of the entire quadtree to begin with, it has the effect of finding the closest leaf node on the outer boundary of the quadtree (sort of a clamping effect)
[QUOTE=KillaMaaki;45671969]I also learned a new trick for octrees which I've used for the octree code used by my sentries (for me anyway - I get the feeling that some people here already know this technique >.>).[/QUOTE]
[img]http://i.imgur.com/xTKuSoW.png[/img]
[QUOTE=KillaMaaki;45671969]Basically, given an octree node with children, you can find which child node a given point is inside of without checking against the child bounds.
Since Octrees are hard to illustrate, I'll do so with a quadtree instead (same basic idea)
The index of each child node is given two bits. The first bit is set for the X direction, the second bit is set for the Y direction. Like so:
[IMG]http://i.imgur.com/QQv2yfo.png[/IMG]
Given a point, and the center point of the parent node, you can calculate which child contains the point by setting each bit as such:
1.) Set the first bit to 1 if the point's X component is greater than the center's X component
2.) Set the second bit to 1 if the point's Y component is greater than the center's Y component.
That works out to something like this in code:
[code]
int idx = 0;
if( point.x >= center.x ) idx |= 2;
if( point.y >= center.y ) idx |= 1;
return children[ idx ];
[/code]
[/QUOTE]
[img]http://i.imgur.com/o4stHbE.png[/img]
[QUOTE=KillaMaaki;45671969]So comparing against child bounding boxes would be, at worst, 16 comparisons (or at best 4 comparisons). Whereas this technique is only 2 comparisons in every situation.[/QUOTE]
[img]http://i.imgur.com/tpFF1Nt.png[/img]
[QUOTE=KillaMaaki;45671969]Extending to an octree is easy enough - add a third bit for the Z direction, and another comparison.
Just kind of a neat trick I think.
EDIT: The funny thing is that, if you don't check to see if the point is inside of the entire quadtree to begin with, it has the effect of finding the closest leaf node on the outer boundary of the quadtree (sort of a clamping effect)
[/QUOTE]
[img]http://i.imgur.com/yuXVAiZ.png[/img]
Thank you, sir, for you have made my day.
EDIT
Clearly, you'll want to organize all of your objects into Node 3, as it is the happiest node of them all.
So, it's the end of the day where I am. I'm burnt out on real game programming, so what better to do than redesign my fake Unity VM ;)
I'm thinking, to maintain realism, it will have significantly fewer registers. To be precise, 9 registers.
[code]
PC (16 bit, program counter)
SP (16 bit, stack pointer)
IA (16 bit, index 1, can be treated as two 8 bit registers as IAH and IAL)
IB (16 bit, index 2, can be treated as two 8 bit registers as IBH and IBL)
EA (8 bit, general register 1)
EB (8 bit, general register 2)
EC (8 bit, general register 3)
ED (8 bit, general register 4)
SW (8 bit, memory switch)
[/code]
Rather than having a number of 32 bit registers, I'm settling for 16 bit registers (hey, it's more retro that way!) plus that last SW register, which will be used to perform something akin to "bank switching" in order to increase the addressable space, as a lot of older games had to do in order to have larger programs (actually, a lot of games would have a bank switch built into the cartridge, and setting it would allow them to switch between several memory chips inside the cartridge)
I'm going to stick with the architecture which is apparently known as a "load/store architecture". That is, memory is only ever interacted with via load/store operations. If, say, a math operation is to be performed, the operands must be loaded into registers, then the operation performed, and finally the results saved back out to memory.
Might experiment with re-implementing the helper methods I used for writing things. One possible thing to add might be helper methods for statically allocating blocks of RAM for "variables", and translating variable names to RAM addresses (at compile time) which would basically allow me to write programs utilizing global variables.
EDIT: Just read up on how stack pointers work in x86. Let's just say mind=blown.
EDIT 2: HOLY SHIT you can use assembly-style labels in C#???
[code]
int index = 0;
goto _CONDITION;
_LOOP:
++index;
_CONDITION:
if (10 != index)
{
// for statements
Debug.WriteLine(index);
goto _LOOP;
}
[/code]
That's valid C#??
Learn something new every day, huh..?
Sorry, you need to Log In to post a reply to this thread.