Location tracking across scenes...

Started by
14 comments, last by Durakken 8 years ago

So, I'm using Unity3D and I'm essentially making a Pokemon clone game... The problem I'm having is that I have "tall grass" that throws you into a different scene where I need to know what set of tall grass i've come from.

i could just create a script on each "tall grass" area or create have a reference list of boxes in the battle scene script... both of which seems to be a horrible amount of work to do and not all that efficient.

So is there any easy way to do this?

Also... similar question with cross scene alignment... where I have, say, a world map scene and a local town scene that i have to walk between... Obviously the 2 scenes will have different grid positions so if it's not just a doorway that there is only 1 space to enter from but a wide area to enter from is there an easy way to map that between the two so its more or less seemless?

Advertisement

I am thinking in the direction of a world with scenes.

You have a world, and in that world are scenes, or rather, only the camera aimed at the scene.

A position in the scene can be translated to a position in that world, by using the camera position and orientation. The other way around works too, of course.

When you leave a scene, you translate the character position from the scene to that world, switch to a different scene, and compute the scene position of the characters from the world.

Not sure how well this would work though, if a scene is a line fragment, positioning would work, but maybe different scenes get in each others way??

Maybe "camera" should just be a simple translation/mapping function instead of a proper 3d camera with all its projection complications.


I have "tall grass" that throws you into a different scene

you mean loads a different level? or moves the camera in the world to some new fixed 3pv point?

from the point of view of a seamless 3d world, "different scene" doesn't make sense (at least to me) - i probably just use a different term.

.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

@Alberth. That's the question.... I have Scene 1 which is a town And Scene 2 which is going to be the "over world". The position used in Scene 1 and Scene 2 use different grids so if the player is at x:100, y:1, z:100 in Scene 1 and the door is say 3 meters big so they can transition anywhere from x:100, x101, or x102 then I have to have something that says that point is the same point on Scene2 which it could be at x540, y1, z634... I'm asking if there is an easy way to do this... I guess I could do global positioning but not sure how well that will work.

@Norman Barrows, It loads a different level... But either way it's a problem because even if I just moved the camera i still have the problem of telling the battle script where i was if I want to have different "tall grass" in a scene spawn different monsters.

Scenes are as best as I can figure a package all the models and scripts that are used for a "level" You generally don't want them getting too big from my understanding and I don't quite get the loading thing, but what I figure is that even though I could have the town in the same scene (as well as the battle stuff) it is best to make a different scene if just for organization purposes so that the editor doesn't have all the NPCs and such loaded up for each town and if I want a question in a given town i can just load that town rather than sifting through everything in 1 giant scene.

@Alberth. That's the question.... I have Scene 1 which is a town And Scene 2 which is going to be the "over world". The position used in Scene 1 and Scene 2 use different grids so if the player is at x:100, y:1, z:100 in Scene 1 and the door is say 3 meters big so they can transition anywhere from x:100, x101, or x102 then I have to have something that says that point is the same point on Scene2 which it could be at x540, y1, z634... I'm asking if there is an easy way to do this... I guess I could do global positioning but not sure how well that will work.

In my world between scenes idea, you could define some coordinate range, for the transition area between Scene 1 and scene 2, let's say from 200 to 202. You would make a translation function from scene1 to the (transition) world, like "if x >= 100 and x <= 102 then return x + 100;".

In scene 2, you do the reverse. From the world transition areas related to scene2, you find the character you translated from scene1. You apply a reverse translation, like "if worldx >= 200 and worldx <= 202 then return vec3(worldx - 200 + 540, 1, 634);"

My code is horribly incomplete, but I hope you get the idea, you make 'transitions areas' between the scenes (a transition area is shared by 2 or more scenes) in a separate world (mostly just a separate coordinate system), and you translate the character coordinates from scene to world to the next scene.

EDIT:

Upon further thought there is no need to have a world filled with transition areas with different coordinates. You can make a new world for each transition area instead.

I once had that problem, too. I solved it the following way (described here using matrix transformations for column vectors):

An exit is a collision area with an own placement CX. It is linked to an entree which also has an own placement CE. When an actor enters the exit area, then the actor's global placement Ag is transformed into the exit's local coordinate system as

AL := CX-1 * Ag

This placement, although being computed local to the exit, is directly re-interpreted as placement local to the entree, i.e.

AL = CE-1 * Ag'

resulting in the placement behind the entree being

Ag' = CE * CX-1 * Ag

Here the placement C of an exit or entree could be modeled using translation, rotation, and scaling as usual

C := T * R * S

so that different scales, orientations, and positions can be considered when desired.

@haegarr I think I get what you're saying...

Are you doing something that no game has done before?
If not, you should post an example of what you want from an existing game.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


Scenes are as best as I can figure a package all the models and scripts that are used for a "level" You generally don't want them getting too big from my understanding and I don't quite get the loading thing, but what I figure is that even though I could have the town in the same scene (as well as the battle stuff) it is best to make a different scene if just for organization purposes so that the editor doesn't have all the NPCs and such loaded up for each town and if I want a question in a given town i can just load that town rather than sifting through everything in 1 giant scene.

EDIT:
Upon further thought there is no need to have a world filled with transition areas with different coordinates. You can make a new world for each transition area instead.

its my understanding that unity takes a "level based design" approach to things. IE everything is a level (a scene) a level has a map, actors, and scripts. every different location in the world should be a different level. not sure how they handle moving from one exit to the next. perhaps a simple lookup table: level[a].exit connects to level[c].exit[d].

so the world is not "seamless". you load levels every time your location / setting changes. if you have a bunch of towns, each should be a level. or perhaps more than 1 if they are big. i personally do huge open seamless game worlds, so i'm not sure how unity would handle outdoor scenes. levels would still have to be small(ish). and then you get the whole paging issue. apparently unreal has large seamless world support. without it, you'd have to roll your own, or settle for smaller outdoor areas and "Loading level..." messages.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Well the general concensus is that if you're doing roughly the same thing you should keep it in the same scene...

With the terrain... I'm running into a several problems... Some of it is because I'm deciding what I want between several different options... but seamless infinite terrain is possible, but you have to write your own script or buy one or find one so that the terrain loads chunks that spawn and despawn as needed. I don't quite get the coding to impliment this... or at least not sanely as I'd want to impliment something like 120km squared amount of terrain divided into 1 or 2km squared chunks and the only way I understand how to do get all those chunks laid out and with the right height map is make it 1 terrain which doesn't help.

what I am currently doing is using a seperate scene for towns which I could do more or less seamlessly provided I can perfectly match the 2 scenes' coordinates so that I can translate between them and have any thing that would be showing between the scenes in the other.

The above is more of a secondary problem though as there are other options if I can't find and impliment the solutions I find... which I have found several, but haven't been in a mental state to be able to try to figure them out.

The main thing I'm concerned with is the "tall grass" thing...

When I load up the scene I pass to a "player state" script that my current map is whatever the name is... I also keep that "player state" updated with the player's coordinates on that map.

When the palyer enters a collider it sets off a number that equates to you will have an encounter in x steps and then when x steps happens, it sends the player to a different scene for battle.

Now Supposing I am on Map "DebugTown" and I have 2 "tall grass" areas that I want to spawn different sets of MOBs...

A simple, but very tedious and I'd guess bad way to do this would have a script attached to each of the tall grass colliders which specifies that specific location. to do this would mean creating possibly hundreds of scripts that equate to about 3 to 6 lines.

Another way is that I could when the player is passed to the battle scene the battle scene reads the current map and then scan through a bunch of hit box zones and if the Current position of the players is in a zone, select from the spawns... This seems like it would be stupid because it opens it up to the situation where the battle scene is called, but the mob is undefined.

Neither way I'm thinking seems like a good idea and If I get the seamless terrain working I'm going to run into this problem...

-----------------

Of course these wouldn't be as big of an issue if I could figure out how to impliment a battle system that is more action base... but the problem there is more of a map design issue. The MOBs I want to range in scale from 1 to 10 meters and the world map to be largely forest, however... the forest doesn't look right if trees are spread out far enough to allow movement for such large MOBs... and then again I'm not quite sure how a forest's tree density would be altered with such monsters running around.

This topic is closed to new replies.

Advertisement