Adam's Lair Forum

game development and casual madness
It is currently 2020/02/25, 04:46

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: SkyLine - Tesbed
PostPosted: 2015/05/16, 17:39 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 354
Location: Out there
Role: Hobbyist
Could someone care to just spend 30 seconds and test this thing of mine?
It's a project I have, always restarting it in any engine/framework in existence.

For some reason, I never happened to make it a full game. Well, I'd better do so now.
And fast.

Bare basics: Left and right to move, space to fly up to the nearest green circle, if you are close enough. When in contact, releasing Space will shoot up the ball according to the angle the magnet is. Visual cues missing, but I'll get there eventually.

Main objective, go over the box.

Anyhoo, here's the thing: https://db.tt/4A4wnONr

I think that sometimes the ball gets repelled at different forces depending on the angle, but it might be me. I'm using ApplyWorldForce(), if there's a better implementation, shoot.

EDIT: For some reason, any change I make to the ball's angular velocity doesn't seem to register. Go figure.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Last edited by eyeliner on 2015/05/16, 21:52, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/16, 17:59 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
That movement when hitting space.. somehow doesn't look "right".

Gfycat Video - Click to Play. [Source]

Is it supposed to be like this?

Quote:
I think that sometimes the ball gets repelled at different forces depending on the angle, but it might be me. I'm using ApplyWorldForce(), if there's a better implementation, shoot.

EDIT: For some reason, any change I make to the ball's angular velocity doesn't seem to register. Go figure.


Any source code from your side could be helpful for coming up with suggestions :D

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/16, 18:11 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 354
Location: Out there
Role: Hobbyist
Ha... How fun... You need to keep space pressed to stick to the magnet. Then, you can rotate around it and then get shot, but wow, you have a gigantic impulse. The same I see in the editor but not when I debug.

And now I've seen that the released "game" is immensely different from what I was used to see.

Here is the control mechanism:
Code:
            if (key[Key.Left]) { mainPhysics.AngularVelocity = -rotatingSpeed; }
            if (key[Key.Right]) { mainPhysics.AngularVelocity = rotatingSpeed; }
            if (key[Key.Space])
            {
                if (closestMagnet == true)
                {
                    Vector2 direction = new Vector2(targetPos.X - mainPos.X, targetPos.Y - mainPos.Y);
                    mainPhysics.ApplyWorldForce(direction.Normalized * 1.5f);
                    spaceKeyDownPreviously = true;
                }
            }
            else
            {
                if (magnetized)
                {
                    if (spaceKeyDownPreviously == true)
                    {
                        //OK
                        Vector2 direction = new Vector2(targetPos.X - mainPos.X, targetPos.Y - mainPos.Y) * -1;
                        mainPhysics.ApplyWorldForce(direction.Normalized * 50);
                        spaceKeyDownPreviously = false;
                    }


I guess I need to take into account A LOT of factors, because everything is different.
The resolution and window options and the speed of the game itself...

Good, good.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/16, 20:37 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
The main difference between editor / debug and release versions is, that release versions usually are VSync'ed or capped to 60 FPS, whereas editor and debug versions can run as fast as they want. To achieve the same experience in both worlds, you need to multiply all your time-dependent calculations by Time.TimeMult.

However, RigidBody.ApplyWorldForce explicitly tells you not to do so - because it does it by itself internally already. I've even tested this two minutes ago, just to be completely sure: When applying a force to a RigidBody, it behaves the same, regardless of game speed, just as it needs to be. So that particular method should be fine as is.

Edit: The only exception here is when your FPS fall below 30, which Duality uses as a hard minimum. Below that, the game will actually get slower, so in case you develop on a machine that is below 30 FPS, it will definitely behave different on regular machines. However, this sounds very unlikely to me ^^

Starting from there, I'd suspect there's some other bit of your gameplay code that is somehow framerate-dependent, i.e. needs a TimeMult treatment. Don't see anything suspicious in the excerpt you posted though. :troubled:

You can test this when you run the game from the editor using Profile Game vs. Run Game, both in the Run menu. It can sometimes also help to create a ProfileRenderer diagnostics Component to see how fast each test is running. You should see something around 16 ms per frame when running the game, and a lot less when profiling it.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/16, 21:31 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 354
Location: Out there
Role: Hobbyist
The excerpt I posted is the whole control logic. There's no more of it. The premise of the game is simple, just roll around and press/release Space. The environment takes care of the rest, and all the timing is taken care of by the physics engine.

I believe that here the problem was in the calibration of the values given. I used big numbers because they felt right, but indeed the Game View correctly reflected the file I posted, with the ball going everywhere.

It should now be more manageable with the values tweaked.

Link here.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/17, 09:57 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
I played around with it some more and I think I got it. I've made some more videos, so you can see what I saw. This first one is your game as you released it, VSync'ed and thus, capped at 60 FPS:

Gfycat Video - Click to Play. [Source]


This second one is where I fiddled with the config files to disable VSync, and I reached around 180 FPS:

Gfycat Video - Click to Play. [Source]


As you can see, while the overall movement and magnet attraction is roughly the same in both cases, jumping off is completely different. I then looked at your code again and think I spotted it:

Code:
if (spaceKeyDownPreviously == true)
{
    Vector2 direction = new Vector2(targetPos.X - mainPos.X, targetPos.Y - mainPos.Y) * -1;
    mainPhysics.ApplyWorldForce(direction.Normalized * 50);
    spaceKeyDownPreviously = false;
}


This is a one-hit impulse, right? But you're applying a continuous force, not an impulse here. This force is designed to be applied every frame, so it will be internally multiplied with Time.TimeMult to counter the effects of variable framerates. However, you're not applying it each frame, but only once, so applying TimeMult is actually wrong.

What you really need is an impulse. Try ApplyWorldImpulse instead. You might have to tweak your values again, but it will look the same across all framerates afterwards :)

One other thing I noticed: In 60 FPS, the ball is sometimes "bouncing" a little when it's already at the magnet. To me, it looks like the magnets might be too bouncy, repelling the ball (check their Restitution values) or the force you're applying for attraction might be too high when they're that near. Maybe you could cap it at a certain distance to make it look a bit smoother?

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/17, 18:25 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 354
Location: Out there
Role: Hobbyist
I appreciate your help, really.
So, I get it. I was testing the game(s) completely unsynched. I type code and F5 in VS, so that was the source of the problem. Glad I got the courage to post this so soon in development.

I don't want it to become too complex. Three keys to do the job. Roll, stick, repel. Catch occasional collectibles and find the way to the other side of the screen.

With your input, I have now become more aware of the differences, so I now resort to running the game from the editor. At least I know what everyone sees.

I also decided that developing a plugin is not for me (yet), so I am at peace and will dedicate my efforts in other ways. I hope one of these days someone posts a guide to make a plugin, or an SDK. I have an idea for a plugin. I just need to know what I am seeing. :)

I'll write a couple of guides on the Wiki. :eh:

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/17, 19:51 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
eyeliner wrote:
I don't want it to become too complex. Three keys to do the job. Roll, stick, repel. Catch occasional collectibles and find the way to the other side of the screen.


Simple games are often the best, and I think that your concept has quite a bit of potential for a nice and small puzzle game with added player skill requirements.

eyeliner wrote:
I also decided that developing a plugin is not for me (yet), so I am at peace and will dedicate my efforts in other ways. I hope one of these days someone posts a guide to make a plugin, or an SDK. I have an idea for a plugin. I just need to know what I am seeing. :)


Building some games will certainly help you getting comfortable with the framework and gathering some experience first can sometimes be the wiser choice.

That said, I'm looking forward to your game! ^^

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/21, 20:31 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 354
Location: Out there
Role: Hobbyist
Now, we have progress!
I have concocted a way to move to the next scene by hitting the end scene trigger.
Still battling with my non-existent artistic ability but I'm confident that using vectorial shapes, some freehand drawings and some creativity, I will be able to make something not worthless. I have some ideas for the graphical aspect of the thing, but I'll need to improve some areas.

I feel confident. ^^

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: SkyLine - Tesbed
PostPosted: 2015/05/21, 21:06 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
eyeliner wrote:
I feel confident. ^^

This is THE most important thing you need. You might feel it's too much to tackle, you might feel your life is pulling you back (like me at the moment.. I come back home after work and I feel that the last I want to see is a line of code ^^)...

BUT I am confident that as soon as this rough patch is over I will be able to get back fully committed to finishing the game.

So be strong, and don't lose your confidence! :mrgreen:

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group