Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411716 Posts in 69402 Topics- by 58450 Members - Latest Member: FezzikTheGiant

May 21, 2024, 09:30:37 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsFlippin' Table Tennis (╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
Pages: 1 [2] 3 4
Print
Author Topic: Flippin' Table Tennis (╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)  (Read 9173 times)
Jeddychan
Level 0
**



View Profile
« Reply #20 on: March 18, 2015, 08:28:04 PM »

So I've sort of had a lack of progress since I had just been slammed with midterms, and then I was SUPER lazy over spring break. I do have some other things to write an update about, and I'm ready to get back into streaming, but I have hit a major stumbling block.

So, since the last update I posted, Unity 5 came out, and as much as I know that it's best practice not to switch between major versions of an engine mid-project, there were a lot of features that I felt would outweigh any issues I encountered in upgrading my unity project.

I've solved all the problems so far, except one. Had to re-do all my materials because of the lighting changes in Unity, and tweak a couple of things, and I had thought I was good. Turns out, Unity 5 broke my table, more specifically, it doesn't like my table's self-righting script.




If anyone has even an inkling of what could be going wrong, I would love to hear it. I've been trying for the past week to figure this one out. I would love to get this fixed so when I'm streaming I can work on more interesting things.
Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
SamuSamu
Level 0
**



View Profile
« Reply #21 on: March 20, 2015, 12:14:02 AM »

Can you post bits of the script or explain the logic behind it?
That would help in figuring out whats wrong.

Edit: When I was reading through the thread I had an idea of the way I would handle the table's physics. I would probably just overwrite the rotation of the table and not use physics for it at all. Maybe locking the rotation on one axis only and calculating how many full flips the table can do based on the power of the flip. If that makes any sense. Smiley
Logged

Creator of Games at Shark Punch
Cyberjackers [In progress]
The Masterplan [Done]
Jeddychan
Level 0
**



View Profile
« Reply #22 on: March 20, 2015, 12:06:56 PM »

Okay, the basics of how the table script works is as follows.

Table in air:
 - Nothing is being controled in the script, the physics engine is making the table tumble normally
 - Rigidbody's center of mass is normal


Table on ground:
 - The table's rotation is being slerped towards being upright
 - Rigidbody's center of mass is shifted towards the legs of the table


The reason why it uses two different things to acheive the flipping, is because in order for the slerping to work on it's own, the speed at which it does it has to be incredibly high depending on how the table is sitting. Having a high value for the slerp kind of makes the table freak out a bit, and look unnatural. Changing the center of mass of the rigidbody essentially weights the feet of the table, and helps the table flip upright with the slerp, and looks "natural" when it works.

There are a few extra things in there so that when the table slows down enough, it stops trying to self-right the table constantly, but that's about it.


At this point, I don't know if I'm going to have to completely re-do the script and have the table self-right using some other method, or if the original script can be fixed, but I have put some thought into how I could, in theory, get the table to self-right in other ways.


EDIT: I was messing around with the script trying to tease out the issue, and it seems like the reason why the table is hopping in the Unity 5 version, is because of the sudden change in center of mass. I can increase the change, and the hopping becomes more erratic. I'm trying to think of a way that I could get it to work, other than by lerping the COM, because I'm not 100% sure if that would work, or if it's even the best solution.
« Last Edit: March 20, 2015, 12:28:17 PM by Jeddychan » Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Zorg
Level 9
****



View Profile
« Reply #23 on: March 21, 2015, 02:01:06 AM »

After your last post i was wondering if you add mass to the table's feet. It's funny you used exactly that solution.

If the change of the center of mass does not work anymore, you could add a force at the table's feet position instead, pointing at the ground, which is basically the same as the gravity solution, but without changing the COM. Smiley
Logged
Mittens
Level 10
*****

.


View Profile WWW
« Reply #24 on: March 21, 2015, 07:03:32 AM »

I really hate unity5's physics, it's broken a bunch of stuff I was working on too
Logged

Jeddychan
Level 0
**



View Profile
« Reply #25 on: March 21, 2015, 11:18:58 AM »

I'm gonna be working on it in a little bit to see if I can't fix the problems, I'm just gutting all the code that is meant to right the table, and then just substitute something else there.

After your last post i was wondering if you add mass to the table's feet. It's funny you used exactly that solution.

If the change of the center of mass does not work anymore, you could add a force at the table's feet position instead

I was actually thinking of something similar, I was trying to figure how I would right a table in real life, and what I would probably end up doing is pushing the point on the table that's the farthest from the ground, because that would end up being the point that's the farthest from where you want the table to tip. Your idea is, as far as I can tell, exactly what I was thinking except on the feet instead of the table top.

I really hate unity5's physics, it's broken a bunch of stuff I was working on too

Is there anything currently that you're stuck with? I may have already had issues with it and figured out how to solve it.
Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Zorg
Level 9
****



View Profile
« Reply #26 on: March 23, 2015, 02:26:38 AM »

I was actually thinking of something similar, I was trying to figure how I would right a table in real life, and what I would probably end up doing is pushing the point on the table that's the farthest from the ground, because that would end up being the point that's the farthest from where you want the table to tip. Your idea is, as far as I can tell, exactly what I was thinking except on the feet instead of the table top.

Yes, i would apply the force to the feet, because it matches your previous approach to drag the center of mass to the feet. Which already worked before the update.

If the table is upside-down, i'd apply a tangential force:

(Red: tangetial to the feet. Green: orthogonal to ground.)
Logged
Jeddychan
Level 0
**



View Profile
« Reply #27 on: March 25, 2015, 07:13:29 PM »

Yes, i would apply the force to the feet, because it matches your previous approach to drag the center of mass to the feet. Which already worked before the update.

If the table is upside-down, i'd apply a tangential force:
(Red: tangetial to the feet. Green: orthogonal to ground.)

That is a lovely graphic. I'll see if I can get some good images of how I got it to work when I post a big update on Friday.
Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Jeddychan
Level 0
**



View Profile
« Reply #28 on: March 27, 2015, 01:42:11 PM »

Alright, so if you didn't catch that I've upgraded to Unity 5 from the post explaining things broke, I've upgraded to Unity 5! Now that I have more features available to me, I could probably just make the main menu using a camera filter, but I made a proper blurred skybox before the upgrade.


I used a modified version of the program CubeMapGen. The program is meant to make diffusely convolved cube maps, which is a fancy term for a blurry skybox. The purpose of blurring a skybox is to use it for lighting. So in other words, it does exactly what I need for the main menu.


This is what it looks like when you open it





The layout for the cubemap looks like this





This is what my skybox looks like laid out properly





And this is what I had all the settings set to (note, I had the resolution "output cube size" value too high and it took forever to render)





After figuring out the skybox is when I upgraded to Unity 5 and had my table break. I tried messing with my existing code that used the center of mass to self-right the table, but it seems that changing the COM was causing issues with the new version of PhysX that Unity 5 uses. I then went on to try using applyTorque on the rigidbody to right it, and that didn't work.

What finally worked was having my script choose one out of eight positions on the top of the table (4 corners, and 4 middles of edges) and then applying a force at the point that is the farthest off the ground.

The fixed script in motion looks something like this (in slow-motion and the arrow indicates where the force was applied)




I've cleaned up the code that makes the crowd jump around. Instead of having a script on each individual, it's now just a single script controlling all of them. In addition to that, I've done the prep-work in the same crowd controller script to get the audience to do the wave, so I'll get a gif of that as soon as I get it working.

Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Zorg
Level 9
****



View Profile
« Reply #29 on: March 27, 2015, 01:51:08 PM »

Nice slomo! :D

What happens if the table is landing upside down? In the GIF it looks like you are constantly changing the force while the table is grounded.
Logged
Jeddychan
Level 0
**



View Profile
« Reply #30 on: March 27, 2015, 02:56:05 PM »

Nice slomo! :D

What happens if the table is landing upside down? In the GIF it looks like you are constantly changing the force while the table is grounded.

Correct, whenever the table hits the ground, the code checks which point is the highest and then adds the force.
Also, great question, it doesn't work that great when the table is totally upside-down, but that doesn't happen that often while playing. I want to add that there's also a sphere collider on top of the table, slightly offset from center, just to prevent the table from landing perfectly square upside-down on the ground.

The table righting correctly from upside-down is unlikely to happen, but when it does, there's like a 50-50 chance it works out well.

Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Zorg
Level 9
****



View Profile
« Reply #31 on: April 01, 2015, 03:44:17 PM »

I have a question concerning your original skybox in blender:
are the clouds and the sun 'simply' sprites you placed on a sky dome?

I want to create a skybox in photoshop and i don't need the part below the horizon. I thought that some ps script existed, which projects a square texture on a half sphere and could give me an output of five images for a skybox.

But it seems i have to build a sky dome in blender, attach the sky texture (warped with photoshop) and render five images with a fov of 90° manually. Is this correct?

Sorry to bother you with my personal questions, but it seems you have gathered some knowledge about skyboxes on your way. I'd be nice if you could help me out. Smiley
Logged
Jeddychan
Level 0
**



View Profile
« Reply #32 on: April 05, 2015, 07:27:44 PM »

But it seems i have to build a sky dome in blender, attach the sky texture (warped with photoshop) and render five images with a fov of 90° manually. Is this correct?

Sorry to bother you with my personal questions, but it seems you have gathered some knowledge about skyboxes on your way. I'd be nice if you could help me out. Smiley

First off, I don't mind answering questions at all, if someone has a legitimate question and I can save them time by helping, I'm happy to. Plus, I would appreciate the same if I was asking someone for help, and it also shows a bit more detail into how I made the game.

 
Here's a side, orthographic view of the dome I made, it's pretty much just a modified sphere.




And here's a perspective view




This is what it looks like, peeking underneath the dome




And here is the texture I made to be applied to the dome





You were right about everything except the warping in photoshop. I didn't have to do any warping whatsoever. Also, if you intended to have a bottom to your skybox, you would need to render out six images with a FOV of 90°.

As for rendering out each camera view manually, I animated it so that it would switch the active camera each frame, and then just rendered out an image sequence animation. For all I know, there could be a better way to render out a cubemap, but I don't know of a way, so I just used 6 cameras to do it.

Hope that helps!
Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
oahda
Level 10
*****



View Profile
« Reply #33 on: April 05, 2015, 11:42:34 PM »

Genious.

Also, the physics changes is making me scared to upgrade, but I realise it's probably just the 3D physics, right? So my 2D game won't break if I upgrade?
Logged

Zorg
Level 9
****



View Profile
« Reply #34 on: April 06, 2015, 07:00:41 AM »

Hope that helps!

Yes, thanks! My approach was a flat dome with a warped polar coordinates texture (UV from top view, no seams). You had a good idea to make a round texture for the top and unwrap the rest. Meanwhile, i decided i do not need a skybox and simply used a plane as a child object of the camera. Roll Eyes Anyway, thank you very much for your detailed description! Smiley

You can render all 6 views in one environment map. Simply add a cube in the center of your dome, add an environment map texture (shadeless) and save the environment map after rendering. Downside: all 6 views are packed in one picture and you have to slice it before adding it to your unity project. I guess your animation is more elegant.
« Last Edit: April 06, 2015, 07:05:59 AM by Zorg » Logged
Jeddychan
Level 0
**



View Profile
« Reply #35 on: April 06, 2015, 10:37:05 PM »

Genious.

Also, the physics changes is making me scared to upgrade, but I realise it's probably just the 3D physics, right? So my 2D game won't break if I upgrade?

Glad you think so, most days I wouldn't call myself that.

I'm not entirely sure if it's just the 3D physics. If I'm not mistaken, the 3D physics uses PhysX, and the 2D uses Box2D. If that's the case, I think you're probably fine. Regardless, even if you were working with 3D physics, you wouldn't have to fix too much unless you were doing some weird stuff like I was with the table's center of mass.

Let me know how upgrading goes if you decide to do it.

Anyway, thank you very much for your detailed description! Smiley

You can render all 6 views in one environment map. Simply add a cube in the center of your dome, add an environment map texture (shadeless) and save the environment map after rendering. Downside: all 6 views are packed in one picture and you have to slice it before adding it to your unity project. I guess your animation is more elegant.

You're welcome. I did know about the environment map thing at the time, but I couldn't figure out how to get it working, so it was just faster for me to set up 6 cameras. Thanks for mentioning it though, it's a cool thing that I actually didn't know about for the longest time.






Just a quick update. Getting the crowd to do the wave has been put on hold for more important things. Since it's sort of a pain to get a bunch of friends all over at the same time to playtest and whatnot, I've been trying to make some bots. The goal isn't to necessarily make bots that can compete against players so much as to have them look like they're real players playing. I mostly just want to use them to record some cool game footage (I sort of want to put this on greenlight, and I'm not gonna do that without a cool video), but if the bots are good enough, or if I have the time to make them better, they may end up in the final version of the game.

What I've been currently doing is trying to figure out the relationship between where the force is applied on the table from a hit, and the resulting velocity. I'm going to need to know this if the bots are going to be able to aim and have a vague idea of where to hit the table to make it go where they want. I've got a separate scene, and an additional script on the table where I can precisely apply forces in certain places to see what happens.




So what I've learned so far from all of this. Rigidbody physics are weird. Say for example I apply the force directly in-line with the center of mass, you would expect, that the table wouldn't rotate, and all the force would go into pushing the table. Now what if the force was applied off-center from the center of mass? I expected that some of the force would go into making the table spin, and that it wouldn't go as far. That turns out to be wrong.

Here's a drawing of the test I described.




Note: Some of what I'm saying might not be 100% accurate because I'm summarizing.

So, regardless of where the force is applied on the table, the linear velocity is the same. The angular velocity however, which is completely separate of linear velocity, varies depending on where the force is applied.

If you're interested in a more in-depth explanation of why this is the case, take a look at this article. Just scroll down almost all the way to the bottom and check section "5.5 Force vs Torque Puzzle".

http://www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf

A moderator on a game development twitch stream that I frequent was kind enough to show me this article to help me understand what was going on. It really helped, especially because it has really good diagrams to go with the explanation.
« Last Edit: April 06, 2015, 11:06:48 PM by Jeddychan » Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
Jeddychan
Level 0
**



View Profile
« Reply #36 on: April 08, 2015, 10:08:44 PM »

Some more cool physics testing stuff which will help me make bots.

Here I've got an invisible cube rigidbody with it's rotation disabled so it can't tumble. It has the same mass as the table and when hit, gets hit with the same force that the table gets hit with. It then adds it's position every so often to a list, and that list gets drawn. So all of this gives me a trajectory for the table.



Note: I'm not going to keep the trajectory estimation this way. While in one of my college classes today I was working out the math formula to get the time of flight from the vertical (y) component of the force vector, and from there I should be able to figure out any other information about the trajectory I need to know.

And like I explained before, no matter where the force is applied on the table, assuming it's the same force and direction every time, the resulting velocity, and in turn trajectory in the table will be the same. The only difference that applying the force in different spots changes is how the table tumbles, which only has a very minor effect on where the table ends up landing because it tends to tumble a bit more after it has hit the ground.

Note how the center of mass of the table (shown by the XYZ cross thing) follows the estimated trajectory path to a T, only straying from the path when it hits the ground and keeps tumbling.




If anyone is interested in specifics, or any of the math, I can scan in my notes, or better, re-do my notes to make more sense and show how I got the formulas I needed and whatnot. I might just do it regardless if I'm feeling so inclined.


EDIT: While messing around with different forces and whatnot, I figured out that my math is flawed, so I'm going to have to take another look at it

EDIT: EDIT: Apparently it wasn't my math that was off, it was when I stopped the timer on the simulated trajectory to be coded wrong, causing the time of flight gotten from the math, and the time of flight gotten from the rigidbody actually traveling the path to be different.
« Last Edit: April 09, 2015, 01:43:34 AM by Jeddychan » Logged

FLIPPIN' TABLE  TENNIS
(╯'□')╯︵ ┻━┻ ︵ ╯('□' ╯)
FTT Devlog

@Jeddychan
11clock
Level 1
*



View Profile WWW
« Reply #37 on: April 09, 2015, 06:12:58 AM »

Best idea for a video game I heard in ages.

Very big fan of mechanics based game design with humor that ISNT purposefully bad controls.
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #38 on: April 09, 2015, 10:11:41 AM »

Literal table tennis!

Also old post but:

-And another friend suggested calling it "Flippin' Table Tennis". I really quite like the last one, because "Flippin'" doesn't really add anything to the name, it's sort of like throwing the F-word in front of it. But what it does do is differentiate it from something generic, and also adds to the pun. My one concern, the same one I had with "Table Flip Tennis", is if it gives away the game before you get presented with the pun. I feel like it doesn't, but I don't truly know because I know what the game is already.

I'll be blunt, I doubt people will even consider taking a look to the game until they already know it's about table flipping, so it's actually probably in your best interests to give it away as soon as possible (don't forget that people will still be wondering how it plays exactly! =P).
Logged
jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #39 on: April 09, 2015, 11:35:03 AM »

since its still being discussed, just want to chime in and say i LOVE the "Flippin' Table Tennis" name  Hand Money Right Hand Money Right Hand Money Right
Logged

Pages: 1 [2] 3 4
Print
Jump to:  

Theme orange-lt created by panic