Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 03:42:15 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsOUT NOW! Dynasty Feud - 2D Local/Online brawler
Pages: 1 ... 5 6 [7]
Print
Author Topic: OUT NOW! Dynasty Feud - 2D Local/Online brawler  (Read 28576 times)
BananaInPajamas
Level 0
*



View Profile
« Reply #120 on: May 23, 2017, 12:14:44 PM »


CAMERA

Hello!

Today we will be tackling a more technical post, although this specific one is really related to design. We will talk about the first version of the camera we have implemented for the game. This will probably be improved and we will add more effects to it, but we will start from the basic. When we planned how the camera for Dynasty Feud should be, we discussed two completely different options:

Static: The whole stage fits in the screen and no movement is required at all.
Dynamic: The camera follows players and adjusts the zoom depending on the distance between them.

Below we can see the differences between them in Dynasty Feud.


As you probably have guessed since we are writing a post about the implementation of a camera we did, the option we finally selected is the dynamic one. Our main reason to go for that option is that the dynamic one fits better with the idea of levels that constantly transform.

So, let's start with the programming part:

LookAt position: To get the position the camera needs to look at, we basically need the center of every point of interest that is registered to the camera. This part is simple because it only requires for us to create a bounding box that includes all the points and the center of that box is where our camera should be looking at.

Code:
// Computes the center of interest between all the objects of interest
private Vector3 ComputeCenterOfInterenst()
{
    // If there are no objects of interest skip
    if (objectsOfInterest.Count == 0)
    {
        centerOfInterest = Vector3.zero;
        return centerOfInterest;
    }

    // Find the corners of the points of interest (create an AABB around them)
    Vector3 maxPoint = objectsOfInterest[0].transform.position;
    Vector3 minPoint = objectsOfInterest[0].transform.position;

    for (int i = 1; i < objectsOfInterest.Count; i++)
    {
        float xPos = objectsOfInterest[i].transform.position.x;
        float yPos = objectsOfInterest[i].transform.position.y;

        if (maxPoint.x < xPos)
            maxPoint.x = xPos;
        if (minPoint.x > xPos)
            minPoint.x = xPos;
        if (maxPoint.y < yPos)
            maxPoint.y = yPos;
        if (minPoint.y > yPos)
            minPoint.y = yPos;
    }

    objectsBounds.max = maxPoint;
    objectsBounds.min = minPoint;

    // the center of the AABB is the center of interest
    centerOfInterest = objectsBounds.center;

    return centerOfInterest;
}

Zoom adjustment: The proper zoom adjustment implies a little more work (not much more). To know if the actual zoom is correct, we have to compute the percentage of the actual screen that is filled by the bounding box that surrounds all the points of interest (the bounding box we computed for the center of interest), we call this screen occupancy. Actually the screen occupancy will be computed separately for the different axes, X and Y. The way to find this values its pretty straight forward, get the farthest point from the center of interest along that axis and convert that point from World coordinates to NDC (Non-device coordinate). That's it! You have a value that is 1 when your Points of interest are just in the corners of the camera and close to 0 when they are really close. Once this value is computed the only thing missing is to change the actual zoom, which is as simple as deciding the screen occupancy fits better at each moment and zoom in when the occupancy is smaller than the selected and zoom out when its bigger.

Code:
// Find distance between farthest point of interest and center of interest in X
Vector2 viewFarthesX = cam.WorldToViewportPoint(farthestXPoint);
Vector2 NDCFarthesX = Transformations.ViewportToNDC(viewFarthesX);

float screenOccupancyX = Mathf.Abs(NDCFarthesX.x - NDCCenterOfInterest.x);

// Find distance between farthest point of interest and center of interest in Y
Vector2 viewFarthesY = cam.WorldToViewportPoint(farthestYPoint);
Vector2 NDCFarthesY = Transformations.ViewportToNDC(viewFarthesY);

float screenOccupancyY = Mathf.Abs(NDCFarthesY.y - NDCCenterOfInterest.y);

// Get maximum occupancy
screenOccupancy = Mathf.Max(screenOccupancyX, screenOccupancyY);

Screen Occupancy = 0.1Screen Occupancy = 0.3
Screen Occupancy = 0.6Screen Occupancy = 0.9

Hope the explanation was somehow clear enough. Have a nice day and see you next time! Grin

Camera Controls have always been the hardest thing for me to program this looks great! Good Job!
Logged
Eneko Egiluz
Level 1
*



View Profile
« Reply #121 on: May 24, 2017, 07:26:41 AM »



And to celebrate our first day on Steam, here you have some keys to play Dynasty Feud FOR FREE!!  Hand Clap Hand Clap

Z3CG3-LPQYN-6WIBX
8JF22-NYCJE-XJGDW
I8CBZ-ZDRYY-FGRD7
9XGJ5-CMLDG-QG56G
2RMDI-P0266-JGGNV
5DEQT-58JJQ-N6I7M
IR6H9-0LTHE-GZQBV
LMW6Z-EFCJV-57E80
W6ZYZ-0YDFD-VA2CY
42V36-HFEEW-QGBQY

If you like Dynasty Feud, review it on Steam please.
Logged

wizered67
Level 1
*


View Profile
« Reply #122 on: May 24, 2017, 06:53:13 PM »

Thanks for putting some keys up! I was lucky enough to grab one and am excited to play, although whenever I try to join multiplayer I'm the only one there Sad Maybe this weekend there will be more players. Congrats on releasing and best of luck!
Logged
francismoy
Level 0
**


View Profile
« Reply #123 on: May 25, 2017, 12:12:30 AM »

Thanks, I got another copy of the game :D Looking forward to playing it!
Logged
Chris MacAdam
Level 2
**



View Profile
« Reply #124 on: May 25, 2017, 08:22:49 AM »

I grabbed one the steam keys. I will check it out and try to leave a review!
IR6H9-*****-***** I grabbed. it was the 4th from the bottom.
The game looks great though!
Logged

Eneko Egiluz
Level 1
*



View Profile
« Reply #125 on: May 30, 2017, 01:44:48 AM »

Thank you guys!  Hand Clap
We are now working in the next patch and gathering all feedback players are leaving on our forums.

You can join our community in Discord through this link: discord.gg/r3ZBhsb
Logged

Eneko Egiluz
Level 1
*



View Profile
« Reply #126 on: June 06, 2017, 03:16:51 AM »

We are now working on the mac version of Dynasty Feud. No plans for Linux yet, but the idea is having the three system working on cross-play during 2017.
We will talk soon about the new balancing patches we added. Thank you to all of you taking part on Discord discussions about it, and remember that you are invited too Wink
Join Dynasty Feud Discord Community


Logged

Eneko Egiluz
Level 1
*



View Profile
« Reply #127 on: June 19, 2017, 04:04:50 AM »

Dynasty Feud DEMO is now available on Steam for local matches. Cgeck our fighting game playing with two Dynasties for free!!!


Links
Steam: http://store.steampowered.com/app/493180/Dynasty_Feud/
Twitter: https://twitter.com/kaia_studios and https://twitter.com/DynastyFeud
Facebook: https://www.facebook.com/kaiastudios/
Discord: https://discordapp.com/invite/r3ZBhsb
Web: http://kaiastudios.com/ and http://dynastyfeud.com

Logged

Pages: 1 ... 5 6 [7]
Print
Jump to:  

Theme orange-lt created by panic