Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Switching ROOMS!; Here's the solution that works
Topic Started: Nov 30 2007, 01:04 AM (4,971 Views)
Links
Member
[ *  * ]
This is old as the world, PLEASE SOMEONE FINALLY CLEARLY explain how to make room switching work without U3D crashing the game.

Because all that was supposed to work led to a crash:

with(all){
if(persistent==false)
instance_destroy();}
room_goto_next();
==> CRASH

external_call(global.u3d_cleanup);
room_goto_next();
==> CRASH

room_goto_next();
==> CRASH

I don't have another Control object in the next room, I know it's persistent, anyone who has a clear idea please finally make it clear for everyone.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Quote:
 
Code:
 
with(all){
if(persistent==false)
instance_destroy();}
room_goto_next();


Do you have a camera?

Could you describe the crashes for each code? Sometimes it's an "Unexpected Error", sometimes a freeze, and sometimes a 'non-render'.
Blog|EHS
Offline Profile Quote Post Goto Top
 
Links
Member
[ *  * ]
I have a camera. It's just a crash, no messages, game just stops responding.

Did anyone ever maned to switch rooms while using U3D??
I've actually never seen it done.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
I'll try to make this as clear and understandable as possible. Therefore two different problems need to be looked at.

Problem 1, Switching from one room to another where both rooms use Ultimate 3D:
First you have to make sure that both rooms have views enabled, that the primary view is enabled and that this view has the same dimensions in both rooms (e.g.: if it's 640*480 in the first room it has to be 640*480 in the second one too). The control object should be persistent, there shouldn't be a second control object in the second room and the camera should either be persistent too, or there should be one in both rooms. Then this piece of code can be placed in the room end event of the control object to get everything working correctly:
Code:
 
with(all){
   if(!persistent && u3d_type!=0){
       Destroy();
   }
}

Switching rooms should be working without any problems then.


Problem 2, switching from a room, which uses Ultimate 3D to a room which doesn't:

Solution 1, recommended if Ultimate 3D needs to be used again lateron:
This solution just disables the rendering output of Ultimate 3D temporarily and makes sure that all objects get destroyed correctly. Again the control object should be persistent! This code can be used in the room end event of the control object then:
Code:
 
with(all){
   if(!persistent && u3d_type!=0){
       Destroy();
   }
}
SwitchView();

If you want to switch Ultimate 3D back to enabled lateron just create a new camera object in a room that has views set up as described above and call SwitchView() again.

Solution 2, if you don't want to use Ultimate 3D again before the game shuts down, usually not appreciated:
This solution deinitializes Ultimate 3D completely, with all of it's objects. It doesn't matter whether the control object is persistent or not, it will destroy itself anyway. Use this code in the room end event of the control object:
Code:
 
with(all){
   if(u3d_type!=0){
       Destroy();
   }
}
global.u3d_initialized=false;
instance_destroy();



I have tried none of the above solutions but in principle they should be working fine. If they don't please let me know, I'll fix the mistakes then.
Offline Profile Quote Post Goto Top
 
Links
Member
[ *  * ]
Different room size - yes they had different sizes, now they're the same size, still crashes.
Control is persistent, no two controls meeting, camera isn't, but there is one in the next room, still crashing.
Added the code, it's working now.

Thanks for the help.
Great job on U3D.
Offline Profile Quote Post Goto Top
 
Linkin
Member Avatar
Forum God
[ *  *  *  *  *  * ]
That last one works fine except if i exit to menu and then play again 3 times it comes up with and error on not being able to create a Direct3d hardware device?
Posted Image
Want something done in Photoshop, make a request Here

Formerly known as DS-Development.
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
I think I will pin this topic because I think it contains the best explanation on how to switch rooms. Now we maybe can avoid new room switching topics.
Offline Profile Quote Post Goto Top
 
ninja
Elite Member
[ *  *  *  * ]
Thank Dr. Best,

I wasn't having too much trouble with it stalling, but at least now I won't have work as hard. I hated having to add a room end event most of the objects in my game or telling the control object each specific thing to destroy when the player is leaving a room. :ph43r:
Offline Profile Quote Post Goto Top
 
daimenworrall
Member Avatar
Creator of The Dark Dimension
[ *  *  * ]
Doesnt work with the fire and water demo..... errors in the reflection cams and with the water (from the cam)
Posted Image
Dimension Five Server Programmer
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Well, if you take these objects out of the context they are supposed to be in it is not very surprising that you cause errors. Just look at the contents of the messages and see whether you can get them fixed. It most likely doesn't have to do with the room switching code itself.
Offline Profile Quote Post Goto Top
 
daimenworrall
Member Avatar
Creator of The Dark Dimension
[ *  *  * ]
Will do ^_^
Posted Image
Dimension Five Server Programmer
Offline Profile Quote Post Goto Top
 
detuhooja
Member Avatar
Advanced Killer
[ *  *  *  * ]
Dr. Best
Nov 30 2007, 06:55 PM
Problem 2, switching from a room, which uses Ultimate 3D to a room which doesn't:

Solution 1, recommended if Ultimate 3D needs to be used again lateron:
This solution just disables the rendering output of Ultimate 3D temporarily and makes sure that all objects get destroyed correctly. Again the control object should be persistent! This code can be used in the room end event of the control object then:
Code:
 
with(all){
   if(!persistent && u3d_type!=0){
       Destroy();
   }
}
SwitchView();

This doesn't work in u3d 2.1?
I tried that in newest sdk and other examples. Of course i got this work older version of u3d.

Get error:
___________________________________________
ERROR in
action number 1
of Other Event: Room End
for object control:

Error in code at line 2:
if(!persistent && u3d_type!=0){

at position 23: Unknown variable u3d_type
<->
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
detuhooja
May 5 2008, 09:01 PM
Dr. Best
Nov 30 2007, 06:55 PM
Problem 2, switching from a room, which uses Ultimate 3D to a room which doesn't:

Solution 1, recommended if Ultimate 3D needs to be used again lateron:
This solution just disables the rendering output of Ultimate 3D temporarily and makes sure that all objects get destroyed correctly. Again the control object should be persistent! This code can be used in the room end event of the control object then:
Code:
 
with(all){
   if(!persistent && u3d_type!=0){
       Destroy();
   }
}
SwitchView();

This doesn't work in u3d 2.1?
I tried that in newest sdk and other examples. Of course i got this work older version of u3d.

Get error:
___________________________________________
ERROR in
action number 1
of Other Event: Room End
for object control:

Error in code at line 2:
if(!persistent && u3d_type!=0){

at position 23: Unknown variable u3d_type

This solution requires that the option "Treat uninitialized variables as value zero" of Game Maker is enabled in the options of the Game Maker project. In Ultimate 3D 2.0 RC and earlier this was the case by default. You can either enable this option yourself now or you can use this modified code:
Code:
 
with(all){
   if(variable_local_exists("u3d_type")){
       if(!persistent && u3d_type!=0){
           Destroy();
       }
   }
}
SwitchView();
Offline Profile Quote Post Goto Top
 
detuhooja
Member Avatar
Advanced Killer
[ *  *  *  * ]
Ok. Thanks, this new code work well
<->
Offline Profile Quote Post Goto Top
 
Gandalf20000
Member Avatar
Geek
[ *  *  *  *  *  * ]
I can't get this code to work:
Code:
 

back=show_question("Would you like to return to the main menu?")
if back=true
{
with(all){
if(u3d_type!=0){
Destroy();
}
}
global.u3d_initialized=false;
instance_destroy();
}

I have uninitialized variables equal 0, so that's not the problem. When I try this, the game just crashes.
Offline Profile Quote Post Goto Top
 
Go to Next Page
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply