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
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!
Just to clarify how my envisioned system works, because I realize I didn't mention this part, the sequence of events in a frame (game-time frame, not necessarily correlated with a visible frame) goes something like this:

1. Player-input forces are applied, AI does its thing, everything gets its "goal velocity" set into its velocity variable.
2. Collisions are resolved in a comparison of "goal positions", no actual positions have been updated yet. The effect of collisions is an adjustment to the velocity of player/monster objects (moving platforms are assumed to be unblockable here). At the end of this, any objects that can't pass through each other should not have overlapping "goal positions".
3. Actual positions all update by their final velocity. That velocity rolls over into the next frame, to be adjusted by inputs.

A notable extra nice thing about this system is that you can just apply gravity to everything, ignoring whether it's on a platform or not, and it will just resolve to no vertical movement in phase 2 if there's a floor there.

Notable disadvantage: you do have to add some special cases if you want any sort of friction to occur (eg. horizontal moving platforms not moving out from under you).

Adbot
ADBOT LOVES YOU

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:
The way I did tile-based collision in my Minecraft clone was via conservative line rasterisation, which would scale down to 2D incredibly easily.

You rasterize a line against your tile grid, and then step through each cell to see if the tile is solid or not. If it is, you can get the intersection of the line to get the collision point, and you can get the collision normal by storing when side of the cell the line entered last. You can test arbitrary rectangles pretty easily by transforming the dimensions of the grid, too.

It's quite fast and reliable in my experience, I'll try and post some code for it on the weekend if anyone's interested.

AntiPseudonym fucked around with this message at 06:03 on Dec 16, 2011

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

roomforthetuna posted:

Just to clarify how my envisioned system works, because I realize I didn't mention this part, the sequence of events in a frame (game-time frame, not necessarily correlated with a visible frame) goes something like this:

1. Player-input forces are applied, AI does its thing, everything gets its "goal velocity" set into its velocity variable.
2. Collisions are resolved in a comparison of "goal positions", no actual positions have been updated yet. The effect of collisions is an adjustment to the velocity of player/monster objects (moving platforms are assumed to be unblockable here). At the end of this, any objects that can't pass through each other should not have overlapping "goal positions".
3. Actual positions all update by their final velocity. That velocity rolls over into the next frame, to be adjusted by inputs.

A notable extra nice thing about this system is that you can just apply gravity to everything, ignoring whether it's on a platform or not, and it will just resolve to no vertical movement in phase 2 if there's a floor there.

Notable disadvantage: you do have to add some special cases if you want any sort of friction to occur (eg. horizontal moving platforms not moving out from under you).
I was thinking more in terms of position displacement for resolving collisions, but I'm pretty sure that's functionally equivalent to this, since it sounds like you're setting velocity for a single physics frame.

Question about your earlier suggestion to resolve 'the closest edges first', in order to avoid internal edges: what is the definition of the closest edge? I was thinking that taking the center of the player (before moving) and finding the nearest edges possible would be a good heuristic; it seems to work in a few example cases I've drawn out. Was this what you had in mind?

In summary, how does this sound?

1) Perform broad-phase stage
2) Calculate tentative new position of actor / other (unblockable and moving) polygons based on velocities
3) Use SAT to get a set of collisions
4) Take the set from (3) and sort by distance from player, nearest first.
5) Resolve each collision, moving the player the minimum displacement vector out of the polygon.
6) When all resolutions are done, check again to see if you're still colliding with anything.
7) If you are, no (reasonable) resolution was possible. Don't move the player at all. Do some additional checks to see if this is due to a moving platform, in which you might need to take a 'crush' action on the player, whatever that is.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

roomforthetuna posted:

1. Player-input forces are applied, AI does its thing, everything gets its "goal velocity" set into its velocity variable.
2. Collisions are resolved in a comparison of "goal positions", no actual positions have been updated yet. The effect of collisions is an adjustment to the velocity of player/monster objects (moving platforms are assumed to be unblockable here). At the end of this, any objects that can't pass through each other should not have overlapping "goal positions".
3. Actual positions all update by their final velocity. That velocity rolls over into the next frame, to be adjusted by inputs.

This sounds pretty close to the idea of speculative collisions. In that system you apply all forces to an object and calculate its new velocity and then check to see if that velocity could possibly cause a collision with another object. If not, great you're done. If it would collide, you do a more detailed calculation to determine the exact time at which the two objects would be just touching, artificially clip your timestep to that moment and change the velocity to reflect the fact that a collision happened.

The only caveat then is that if you have a complex system with many objects the corrections applied to one object's position may affect the "will it collide" decision of another object. In that case you might need to iterate the system a few times to get all possible collisions to resolve in a stable way.


e: I just noticed a new article on collision detection for 2D platformers sitting in my news feed. I haven't read through it super closely (other than to gag a little on his class hierarchy) but he walks through doing AABB collisions for a tile-based world with special cases for internal edges, etc.

PDP-1 fucked around with this message at 18:17 on Dec 16, 2011

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!

Orzo posted:

I was thinking more in terms of position displacement for resolving collisions, but I'm pretty sure that's functionally equivalent to this, since it sounds like you're setting velocity for a single physics frame.
Not quite the same - I have the adjusted velocity carry over into the subsequent frames. If you just resolve the position then this happens:

The cyan blob being the 'before' position, the red being the penetrating position, and the green being the result - you see the blob moved the same distance per frame in the two versions, so it was falling at the same speed, but it resolved to a position further across the second time because the 'before' frame happened to be a little closer.

As for what happens the next frame - I don't know, it depends what you did to your velocities. If you didn't change them while resolving then you'll slide away down the entire slope, because you'll just keep on falling into the floor like that.

In my version, the same thing happens in this first frame, but in the second frame you've retained more velocity in the first example than the second, so the third frame ends up in approximately the same position both ways. You do need to add something for friction though, or gravity will still slowly slide you down the slope.

The resolution is actually the same resolution, it's done by adjusting the position, so the math used is identical, but the position is adjusted in the velocity, before it's applied, rather than by adjusting the position. The only difference is the roll-over. You can actually do this without storing velocities at all, instead storing "previous frame position" and "this frame position" and using the difference as the running velocity. So you might be talking about that, in which case yes, the results are identical. (There are actual real physics engines that use this model, but I can't remember what it's called, neither the model nor an engine.)

quote:

Question about your earlier suggestion to resolve 'the closest edges first', in order to avoid internal edges: what is the definition of the closest edge? I was thinking that taking the center of the player (before moving) and finding the nearest edges possible would be a good heuristic; it seems to work in a few example cases I've drawn out. Was this what you had in mind?
I would do it by drawing a velocity-direction line from the closest point on the player to the edge, and measuring the distance of that line (note; since all lines compared are going to be the same direction, you only need to check the distance on the longer axis to find the shortest line, no need for x^2 * y^2). Your way would probably work fine and be simpler, but I'd be more confident in mine not making any mistakes. If you're not sure which player-point is closest, it wouldn't hurt to just check them all, since you'd only be checking against the 2 or 3 things that bounding boxes suggest might collide.

And I wouldn't bother sorting the list of collisions, I'd just find the single closest one and resolve it then repeat - the second closest might not be a collision at all after the first one resolves, or might still be second closest to a new collision that was brought in by the adjustment, and since you're doing an additional pass anyway, it only adds complexity to have a sorted list.

Problem! If you fall into a V-shaped gap, the resolution of one wall will always push you slightly into the other wall, getting less far in with each iteration. Distinguishing this from being crushed between two platforms is an exercise left to the reader! (Actually it's not too hard, simply keep track of the smallest adjustment distance you've made each iteration, and if it doesn't decrease over the course of a few iterations then you're being crushed.) If you work with pixel-sized steps then the V-shape will resolve eventually, it's only a problem when you can resolve in very tiny steps because it will keep making smaller and smaller steps.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I like how you left it as an exercise to the reader and then explained it immediately anyway. Anyway thanks, good advice all around.

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!

PDP-1 posted:

This sounds pretty close to the idea of speculative collisions. In that system you apply all forces to an object and calculate its new velocity and then check to see if that velocity could possibly cause a collision with another object. If not, great you're done. If it would collide, you do a more detailed calculation to determine the exact time at which the two objects would be just touching, artificially clip your timestep to that moment and change the velocity to reflect the fact that a collision happened.
It's similar, but simpler, because you don't mess with the timestep. The downside is the results aren't quite as accurate as with the timestep-clipping, and it might be trickier to implement well-behaved friction in my system.

Many of the same problems exist in both systems - a v-shaped gap with floating point positions could reduce the timestep to near-zero with the speculative collisions just as it could spend a lot of iterations bouncing you back and forth in smaller and smaller steps in my system.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

roomforthetuna posted:

You can actually do this without storing velocities at all, instead storing "previous frame position" and "this frame position" and using the difference as the running velocity. So you might be talking about that, in which case yes, the results are identical. (There are actual real physics engines that use this model, but I can't remember what it's called, neither the model nor an engine.)
Verlet integration?

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!

ynohtna posted:

Verlet integration?
That's the one, thanks. I made a little jelly-physics engine using Verlet a while back, but never really did anything with it.

roomforthetuna fucked around with this message at 20:49 on Dec 16, 2011

brian
Sep 11, 2001
I obtained this title through beard tax.

If you're not away Ludum Dare 22 starts in like 5 and a half hours!

It's really fun if you fully commit and great for people who are just getting into game development for learning or people who just want a challenge!

PalmTreeFun
Apr 25, 2010

*toot*

brian posted:

If you're not away Ludum Dare 22 starts in like 5 and a half hours!

It's really fun if you fully commit and great for people who are just getting into game development for learning or people who just want a challenge!

This would be great if I didn't have exams starting Monday. They really picked a lovely time to do this, at least for me.

ambushsabre
Sep 1, 2009

It's...it's not shutting down!

PalmTreeFun posted:

This would be great if I didn't have exams starting Monday. They really picked a lovely time to do this, at least for me.

That's too bad! This is actually the first one in a while I'll be able to really dedicate myself too, so wish me luck! I'm also going to be streaming for my friends so they can watch the whole process and also so I can make a sweet timelapse later on. Gonna be fun!

PalmTreeFun
Apr 25, 2010

*toot*
Well good luck to you! :) I'll be busy finishing up economics homework.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
Any chance anyone in here has used Stencyl?

We're looking at doing a quickie Flash/Facebook game, just to get a handle on how all the hooks work (PHP, SQL, integration into Facebook, porting result to iOS, etc). Super simple, about a month of dev, etc. Stencyl looks like it might be handy for doing the bit of Flash logic (it's really just a game of clicking and some animated UI elements), but it's unclear if we'd be able to take that result and then add the necessary PHP et al glue code.

I'm especially unclear what would happen when we pushed it to iOS side, and whether we'd be able to wrap the result properly with Gamecenter and similar, or no.

Medieval Medic
Sep 8, 2011

Shalinor posted:

Any chance anyone in here has used Stencyl?

We're looking at doing a quickie Flash/Facebook game, just to get a handle on how all the hooks work (PHP, SQL, integration into Facebook, porting result to iOS, etc). Super simple, about a month of dev, etc. Stencyl looks like it might be handy for doing the bit of Flash logic (it's really just a game of clicking and some animated UI elements), but it's unclear if we'd be able to take that result and then add the necessary PHP et al glue code.

I'm especially unclear what would happen when we pushed it to iOS side, and whether we'd be able to wrap the result properly with Gamecenter and similar, or no.

I fiddled with Stencyl a bit during the lastest game making competition although I didn't compete, though back then I don't think iOS was supported yet. It is pretty nifty. Haven't really used it since, because I found I didn't have the time back then to make anything proper, just some throwaway games and ideas.

Aaronicon
Oct 2, 2010

A BLOO BLOO ANYONE I DISAGREE WITH IS A "BAD PERSON" WHO DESERVES TO DIE PLEEEASE DONT FALL ALL OVER YOURSELF WHITEWASHING THEM A BLOO BLOO
Has anyone used ZeroMQ for any length of time? I'm looking to create what's essentially a multiplayer roguelike (I'm not looking to do anything that fancy - just basically sending JSON strings from the client and back again to the draw function of the client if need be) and it's by far the quickest and most straightforward way to get a client/server up and running. I've not yet tested it over the internet, and there's nothing leaping out at me in the docs / use cases that says OH GOD DON'T USE THIS OVER THE INTERNET (they say you should use a VPN or something, but the only technical falldown is that earlier versions of ZMQ fell on their arse when hit by malformed packets, but that appears to be all fixed in the version I'm using)

I'm using Python if that makes any difference, and I know that means I should be using Twisted, but I really like ZeroMQ. I got a basic client / server going ping-pong in like 10 lines and every time I look at Twisted it just makes my head spin.

Aaronicon fucked around with this message at 21:18 on Dec 18, 2011

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal
I'm using Json over ZeroMQ in Python for some internal tools at work. It's great! If you need to do multithreading stuff in your server just fork off new processes and communicate between them with inprocess sockets.

I've not exposed anything to the internet but I can't imagine there's any problems except those of authentication. I imagine that's why they're talking about VPNs; Instead of layering all that crap in your messaging protocol, just secure the network.

StealthArcher
Jan 10, 2010




So hey thread's been helpful before so why not ask around while I'm thinking on it.

Same project, Terraria like setup, 2d, blokz an poo poo. The stuff here helped me create what so far seems to be working on the memory front, so now I need to ask one thing and confirm another.


Physics: I want to have circular objects, and other item physics in the game. Now, Box2D would work for this normally, but we're talking a world made up of voxel chunks that can change constantly.

The amount of memory and CPU time that would be wasted attempting to keep track of this entire (up to 10x10k for 100 million block) world as small Box2D cube shapes would be ridiculous.

On this note, if you have worked with Box2D more then I have (probably a certainty if you've really done much with it) might you have an idea how to fix this issue? The world will have other living NPCs and such in it so physics need to be all across the active world. Trailing worlds have more broad macro effects, so physics won't be active on them.


For the second quicker question, I have an array of chars acting as 8 bit flags for the voxels on the map. Would the easiest method to test if a flag is active a bitwise AND, with 8 corresponding chars with each having 1 bit active (ie. char x = 1, char y = 2, char z = 4, and so on).

DancingMachine
Aug 12, 2004

He's a dancing machine!

StealthArcher posted:

So hey thread's been helpful before so why not ask around while I'm thinking on it.

Same project, Terraria like setup, 2d, blokz an poo poo. The stuff here helped me create what so far seems to be working on the memory front, so now I need to ask one thing and confirm another.


Physics: I want to have circular objects, and other item physics in the game. Now, Box2D would work for this normally, but we're talking a world made up of voxel chunks that can change constantly.

The amount of memory and CPU time that would be wasted attempting to keep track of this entire (up to 10x10k for 100 million block) world as small Box2D cube shapes would be ridiculous.

On this note, if you have worked with Box2D more then I have (probably a certainty if you've really done much with it) might you have an idea how to fix this issue? The world will have other living NPCs and such in it so physics need to be all across the active world. Trailing worlds have more broad macro effects, so physics won't be active on them.


For the second quicker question, I have an array of chars acting as 8 bit flags for the voxels on the map. Would the easiest method to test if a flag is active a bitwise AND, with 8 corresponding chars with each having 1 bit active (ie. char x = 1, char y = 2, char z = 4, and so on).

Haven't dealt with this in 2D but 3D solutions apply I imagine. You probably need to LOD your NPC and physics behavior outside a "reality bubble" around the player. It's unlikely you really need frame-to-frame level behavior 20 screens away from the player. Doing some kind of update the approximates real behavior every second or more would maintain the illusion that the world exists beyond the player's immediate vicinity. If you want to get really fancy you can go to a hierarchy of LODs (frame updates within a couple screens, 1 second updates at 3-15 screens, 1 minute updates farther out, etc.).

Sliding around the origin of your physics world as the player moves around is a pain in the rear end, I know. Not sure how hard that is to do in box2d.

StealthArcher
Jan 10, 2010




DancingMachine posted:

Haven't dealt with this in 2D but 3D solutions apply I imagine. You probably need to LOD your NPC and physics behavior outside a "reality bubble" around the player. It's unlikely you really need frame-to-frame level behavior 20 screens away from the player. Doing some kind of update the approximates real behavior every second or more would maintain the illusion that the world exists beyond the player's immediate vicinity. If you want to get really fancy you can go to a hierarchy of LODs (frame updates within a couple screens, 1 second updates at 3-15 screens, 1 minute updates farther out, etc.).

Sliding around the origin of your physics world as the player moves around is a pain in the rear end, I know. Not sure how hard that is to do in box2d.

Would be fine if it was going to be SP only, but I have to program everything with servers in mind.

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(

brian posted:

If you're not away Ludum Dare 22 starts in like 5 and a half hours!

It's really fun if you fully commit and great for people who are just getting into game development for learning or people who just want a challenge!

I entered!
It was my first LD since it's always near exams for me, but not this time!
My game is kinda bleh but I'm happy finishing something and not giving up. Here's my entry: http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=7596

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

StealthArcher posted:

Physics: I want to have circular objects, and other item physics in the game. Now, Box2D would work for this normally, but we're talking a world made up of voxel chunks that can change constantly.

I made a 3D voxel world with changeable geometry, and I handled the physics by generating the world structure immediately surrounding the player on each frame via a marching cubes algorithm and then testing for collisions with the result.

In other words, you start with an array of raw voxel data - typically a single floating point value that indicates how 'full' each cell is. If you know your player's location and velocity you can figure out which cells they can possibly collide with, so run marching cubes (squares for 2D) on those cells to get a list of triangles (line segments) that make up the local geometry and test for player collisions against that set.

This sounds horribly inefficient to do, but in reality the number of cells that your player can possibly interact with is very limited, marching cubes/squares is pretty fast, and you can calculate an upper bound on the number of solid objects that could possibly be generated and then use a fixed array to store them all to minimize the garbage generated per frame. It ended up working better than I thought it would.

StealthArcher posted:

For the second quicker question, I have an array of chars acting as 8 bit flags for the voxels on the map. Would the easiest method to test if a flag is active a bitwise AND, with 8 corresponding chars with each having 1 bit active (ie. char x = 1, char y = 2, char z = 4, and so on).

Logical operators are very fast, name each bitmask as a constant value like const char FOO_FLAG=1, const char BAR_FLAG=2, etc and then use OR operations to set the flags and AND operations to test.
code:
someFlag |= FOO_FLAG;        // sets foo
if((someFlag & FOO_FLAG)!=0) // tests foo, might not need !=0 in some languages

Senso
Nov 4, 2005

Always working

Aaronicon posted:

Has anyone used ZeroMQ for any length of time?

I use it at work (the Python module), but only for IPC stuff and I love it. I don't see why it shouldn't work over the internet.

Winkle-Daddy
Mar 10, 2007
Hey game thread! I'm brand new to game development and the only "programming" languages I even remotely know are PHP and Perl with a tad of Python, C++ and JavaScript. My favorite language by far is Python so I decided that Panda 3D would be a lot of fun to learn.

Is there anyone here that knows Panda3D at all? If so, I have a question! I'm building my very first "first person" controller with mouse look in the engine and the way I built it was probably wrong but it works decently well. Almost decently well; I can go forward and backward, I can also free look with the mouse. What I can't for the life of me figure out how to do is add strafing.

Here's the code I'm using:

code:
class Controls(DirectObject):
    def __init__(self):
        self.mouseChangeX = 0
        self.mouseChangeY = 0
        self.windowSizeX = base.win.getXSize()
        self.windowSizeY = base.win.getYSize()
        self.centerX = self.windowSizeX / 2
        self.centerY = self.windowSizeY / 2
        self.H = base.camera.getH()
        self.P = base.camera.getP()
        self.pos = base.camera.getPos()
        self.sensitivity = .5
        self.speed = .2
        self.keyboardSetup()
This is where I set up all my variables (obviously) for my controller object.

code:
    def keyboardSetup(self):
        self.keyMap = {"forward":0, "back":0, "left":0, "right":0}
        self.accept("w", self.setKey, ["forward", 1])
        self.accept("w-up", self.setKey, ["forward", 0])
        self.accept("s", self.setKey, ["back", 1])
        self.accept("s-up", self.setKey, ["back",0])
        self.accept("a", self.setKey, ["left", 1])
        self.accept("a-up", self.setKey, ["left",0])
        self.accept("d", self.setKey, ["right", 1])
        self.accept("d-up", self.setKey, ["right",0])
        self.accept("escape", sys.exit)
I create a dictionary of my controls that just uses Panda's listener event.

code:
    def movement(self, task):
        mouse = base.win.getPointer(0)
        x = mouse.getX()
        y = mouse.getY()
        if base.win.movePointer(0, self.centerX, self.centerY):
            self.mouseChangeX = self.centerX - x
            self.mouseChangeY = self.centerY - y
            self.H += self.mouseChangeX * self.sensitivity
            self.P += self.mouseChangeY * self.sensitivity
            base.camera.setHpr(self.H , self.P, 0)
        self.walk()
        return Task.cont
This is the mouse looking part.

code:
    def setKey(self, key, value):
	    self.keyMap[key] = value
This is just a simple function that I use to modify the controller dictionary data for key presses.

code:
    def startMovement(self):
        base.win.movePointer(0, self.centerX, self.centerY)
        taskMgr.add(self.movement, 'movement')
This is what's actually called after the controller object is created that starts everything.

code:
    def walk(self):
        dir = base.camera.getNetTransform().getMat().getRow3(1)
        dir.setZ(0)
        dir.normalize()
        if (self.keyMap["forward"] != 0):
            self.pos += dir * self.speed
            base.camera.setPos(self.pos)
        if(self.keyMap["back"] != 0):
            self.pos -= dir * self.speed
And finally, this is where my problem is. The first line within the function is my direction stored as a vector. I haven't implemented jumping yet so I always set Z to 0. It's easy enough when I press "w" to make the camera move in the direction the mouse is pointing. What I can't for the life of me figure out how to do within Panda 3D is how to move parallel to the direction the mouse is currently facing (with a and d keys).

Any ideas of what I'm looking for? I'm better at Python then I am at Panda or game logic in general at this point so maybe I'm just missing some kind of vocabulary that I can use my google-fu in conjunction with to get me to the right answer?

I appreciate any help you might be able to give, Thanks!

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!

Winkle-Daddy posted:

What I can't for the life of me figure out how to do within Panda 3D is how to move parallel to the direction the mouse is currently facing (with a and d keys).
You mean perpendicular. The answer is that you want to do a vector cross product of the mouse-direction and the up axis - that will give you the direction that's perpendicular to the way you're facing and on the plane you're moving on.

Winkle-Daddy
Mar 10, 2007

roomforthetuna posted:

You mean perpendicular. The answer is that you want to do a vector cross product of the mouse-direction and the up axis - that will give you the direction that's perpendicular to the way you're facing and on the plane you're moving on.

Yes, thank you perpendicular :downs:

What I'm having a hard time with, if I print the value of dir, I see:

code:
VBase3(-0.130447, 0.990841, -0.0348995)
So, I'm using a vector for the direction; and I stumbled upon this method of moving smoothly completely by accident. So I'm having a hard time figuring out how to transform that vector into a direction I can use for perpendicular movement. I've only ever built side scrolling games before where relative movement wasn't really an issue.

But I will do some more googling and hopefully I can find a solution. Not many people use Panda 3D so it can be challenging to find good resources.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Winkle-Daddy posted:

Yes, thank you perpendicular :downs:

What I'm having a hard time with, if I print the value of dir, I see:

code:
VBase3(-0.130447, 0.990841, -0.0348995)
So, I'm using a vector for the direction; and I stumbled upon this method of moving smoothly completely by accident. So I'm having a hard time figuring out how to transform that vector into a direction I can use for perpendicular movement. I've only ever built side scrolling games before where relative movement wasn't really an issue.

But I will do some more googling and hopefully I can find a solution. Not many people use Panda 3D so it can be challenging to find good resources.

Like roomforthetuna said, the thing you are looking for is a vector cross product. If you take the cross product of two vectors the result is a third vector that is perpendicular to the other two. If you take the cross product of your dir vector with a vector that represents the 'up' direction, the result will be a new vector that points sideways relative to the direction that you are looking.

In pseudocode:
code:
Vector3 upVector = new Vector3(0,1,0);
Vector3 localRightVector = lookDirectionVector.Cross(upVector);
        localRightVector.Normalize();
The only caveat here is that if lookDirectionVector and upVector are identical (i.e. the player is looking straight up into the sky) or completely opposite (the player is looking straight down into the ground) the result is a zero vector that will cause problems, so you need some way to make sure that never happens.

Winkle-Daddy
Mar 10, 2007
Awesome, I get what you're saying now. Thanks for the help, I should be able to get this worked out with that. It almost makes me miss the ability to just add a FPS pre-fab controller in unity.

Rupert Buttermilk
Apr 15, 2007

🚣RowboatMan: ❄️Freezing time🕰️ is an old P.I. 🥧trick...

Shalinor posted:

Any chance anyone in here has used Stencyl?

We're looking at doing a quickie Flash/Facebook game, just to get a handle on how all the hooks work (PHP, SQL, integration into Facebook, porting result to iOS, etc). Super simple, about a month of dev, etc. Stencyl looks like it might be handy for doing the bit of Flash logic (it's really just a game of clicking and some animated UI elements), but it's unclear if we'd be able to take that result and then add the necessary PHP et al glue code.

I'm especially unclear what would happen when we pushed it to iOS side, and whether we'd be able to wrap the result properly with Gamecenter and similar, or no.

http://www.stencyl.com/

It's officially all set up for mobile now. As for putting in your own code, I think at any point in time, you can look at the ACTUAL code of the thing. Whether that just limits you to Actionscript or not, I'm not 100% sure on.

EDIT: Actually, you may already know this, sorry if this is entirely unhelpful :smith:

EDIT 2:

https://www.youtube.com/watch?v=1wr9rgE0ta8

I don't know anything about Gamecentre, but they mention it in this video.

EDIT 3: I have a question, and I figure it's best to ask it here, rather than add a new post...

Is Unity worth it for 2D development? I'm aware of the 2D toolkit, and I'll be picking it up, I guess I'd just rather learn Unity, which I can then use to make whatever I want, rather than work in a program that strictly ONLY does 2D.

Rupert Buttermilk fucked around with this message at 19:51 on Dec 20, 2011

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Rupert Buttermilk posted:

http://www.stencyl.com/

It's officially all set up for mobile now. As for putting in your own code, I think at any point in time, you can look at the ACTUAL code of the thing. Whether that just limits you to Actionscript or not, I'm not 100% sure on.

EDIT: Actually, you may already know this, sorry if this is entirely unhelpful :smith:
Yeah, I know the feature exists, I just don't know how useful it is.

I'm just... eh, torn. I feel like I should use Flixel, Stencyl, one of these - just for the experience of it, and because it'll be handy to know for the upcoming Game Jam. Just not sure which is the right choice, when doing a Facebook game that really has nothing to do with a little dude running and jumping.

Kinda leaning toward Flixel at this point. I realize it's still largely focused on "a little dude running and jumping," but I believe it's a mature enough library to be pretty flexible at this point. (and I realize Flixel lives inside Stencyl, but Stencyl is most certainly focused toward "a little dude running and jumping")

Svampson
Jul 29, 2006

Same.

Rupert Buttermilk posted:

Is Unity worth it for 2D development? I'm aware of the 2D toolkit, and I'll be picking it up, I guess I'd just rather learn Unity, which I can then use to make whatever I want, rather than work in a program that strictly ONLY does 2D.

I have been using Unity for the last two weeks, and I think it's great for 2D stuff (I'm using 2D Toolkit for handling the sprites and it works great), altough I'm doing 2D sprites with 3D environments so not sure how good it is with tilesets and if you want really smooth and good 2D platformer physics you might want to consider coding your own (I used flixel's code as a base for mine, which worked great)

Also really fun to mess around with Trail Renderers and crazy camera manipulation when using a 3D enviorment

Svampson fucked around with this message at 20:31 on Dec 20, 2011

Rupert Buttermilk
Apr 15, 2007

🚣RowboatMan: ❄️Freezing time🕰️ is an old P.I. 🥧trick...

Svampson posted:

I have been using Unity for the last two weeks, and I think it's great for 2D stuff (I'm using 2D Toolkit for handling the sprites and it works great), altough I'm doing 2D sprites with 3D environments so not sure how good it is with tilesets and if you want really smooth and good 2D platformer physics you might want to consider coding your own (I used flixel's code as a base for mine, which worked great)

Also really fun to mess around with Trail Renderers and crazy camera manipulation when using a 3D enviorment

Oh my god, I DEFINITELY want to play that when it's done.

I'm a sound designer and composer as a day job, so if you need any help that way, let me know.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
To roomforthetuna and whoever else was following the discussion about collision detection resolution in 2D:

I've been pretty busy with other stuff and haven't gotten around to implementing my proposed solution which can be found near the top of the page. But in the meantime I think I've come up with a simpler algorithm that I hope covers all cases. What I'm looking for are examples where it breaks down and fails. Here it is in a nutshell, after broad-phase:

1) Get list of player-world intersections and resolution vectors.
2) For each item in the list, move the actor to the proposed location according to the resolution vector. See if the new position causes collisions with any of the rest of the world.
--a) If not, move to this position and finish the algorithm.
--b) If so, try again with the next intersection.
3) If none of the resolution vectors from (2) work, instead perform an iterative resolution, pushing the actor out of the intersection polygons one-by-one. If the iteration count is too high or isn't making 'progress' (displacement vectors are not getting smaller and smaller) the player is 'crushed'.

Note that when I say 'move' the actor it's speculative, no actual actor movement from the origin occurs until a valid resolution is found.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
This is a really neat thing, and I want to throw money at this thing in released game form.

Are you thinking full on RPG, or is this more of an arena'y combat'y thing?

Svampson
Jul 29, 2006

Same.

Shalinor posted:

This is a really neat thing, and I want to throw money at this thing in released game form.

Are you thinking full on RPG, or is this more of an arena'y combat'y thing?

Thanks! It will be a metroidvania game but with a bigger focus on the combat/RPG elements

I aim to make it long and polished enough to warrant a throw-money-at-it compatible release but it's still in the super early stages so we'll see how it turns out :)

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!

Rupert Buttermilk posted:

Is Unity worth it for 2D development?
I was playing the demo of Max and the Magic Marker, made with Unity, a few days ago, and that leads me to say probably yes.

Orzo - that sounds like it would work fine, and I don't see any cases where it would explode, though I don't think it sounds simpler than what I was suggesting.

Rupert Buttermilk
Apr 15, 2007

🚣RowboatMan: ❄️Freezing time🕰️ is an old P.I. 🥧trick...

roomforthetuna posted:

I was playing the demo of Max and the Magic Marker, made with Unity, a few days ago, and that leads me to say probably yes.

Ok, wow. This gives me all the hope I need to soldier on.

Anyone else have any neat 2D Unity demos? Or even just really fantastic Unity demos in general?

The Glumslinger
Sep 24, 2008

Coach Nagy, you want me to throw to WHAT side of the field?


Hair Elf
I am having the absolute dumbest XNA issue. It seems that when I am trying to draw using DrawUserPrimitive, I am getting a phantom offset.

code:
SharedGraphicsDeviceManager.Current.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertices, 0, vertices.Length/3);
I checked that the array has the correct values. When I messed with it, I saw that it would only draw a triangle based on the 1st,2nd and 3rd elements in the array, ignoring the 0th, 4th and 5th.


Anyone have a clue what I am doing wrong?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
So you're drawing a triangle strip. I don't understand why you have vertices.length/3, because to draw N triangles you need N+2 verts. TriangleStrip starts with the first three verts, draws the first triangle, and then takes the new vert from the list and then draws the next triangle with the previous two vert and the new vert. To draw a plane:

code:
var verts = {
    new VertexPositionColor(new Vector3(0,   0,   0), 0xFF0000),
    new VertexPositionColor(new Vector3(100, 0,   0), 0x00FF00),
    new VertexPositionColor(new Vector3(100, 100, 0), 0x0000FF),
    new VertexPositionColor(new Vector3(0,   100, 0), 0xFF00FF)
};

DrawUserPrimitives<VertexPositionColor>(Primitives.TriangleStrip, vertices, 0, 4);
The ordering is important here. We first draw a (0, 0)->(100, 0)->(100, 100) triangle and then draw a (100, 0)->(100, 100)->(0, 100) triangle.

I'm not sure if XNA gives you vertex buffer objects. In OpenGL, an alternate way to do this would be to allocate a VBO, fill it with vert data, and then reference an index into the vert array when drawing.

Adbot
ADBOT LOVES YOU

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
The number of primitives in a triangle strip is (numVerts-2), not numVerts/3

efb

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