Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Yakuzza on September 25, 2012, 11:50:49 AM

Title: How does Scene.GetLayer works?
Post by: Yakuzza on September 25, 2012, 11:50:49 AM
Hi!
I've tried to figure out how GetLayer works. But for some reason my code doesnt work
Code: [Select]
#include "scripts\base.inc"


var layer = Scene.GetLayer("Cam2");


on "LeftClick"
{
actor.GoTo(1105, 761);
actor.TurnTo(DI_DOWN);
layer.Active = true;
Scene.SetActiveCamera("Camera002");
}

Clearly there are 2 layers in the scene.
is there something else i should to in order to swith the layer?
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 25, 2012, 12:28:47 PM
the code is correct.

Try:

Code: WME Script
  1.  
  2. var layer = Scene.GetLayer("Cam2");
  3. Debug.Log(layer);
  4.  
  5.  

if result is null, it's most likely name mismatch (case sensitive etc.)
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 25, 2012, 08:52:09 PM
Thanks metamorphium
But it just gives me an error Error@line 10: Trying to call method of a non-variable Debug
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 08:05:40 PM
oh. it's Unity. sorry about it.

Game.LOG, not Debug.Log
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 08:49:36 PM
it says [layer]
what am i doing wrong?
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 08:58:51 PM
okay so the code is obviously correct. :) Now you need to tell us more about what are you trying to achieve.
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 09:07:13 PM
What i'm trying to do is simple really
Switch background image along with the gamera
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 09:20:04 PM
um. and how the scene looks like? Are you sure you are switching layer and not entity? Post your scene definition here.
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 09:25:25 PM
here you go
(http://oi50.tinypic.com/98dnr7.jpg)

and the script
Code: [Select]
#include "scripts\base.inc"


var layer = Scene.GetLayer("Cam2");


on "LeftClick"
{
actor.GoTo(1105, 761);
actor.TurnTo(DI_DOWN);
layer.Active = true;
Scene.SetActiveCamera("Camera002");
Game.LOG(layer);
}

The thing is that camera is actually switching. But the background isnt
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 09:30:52 PM
okay, so it's obvious.

Your scene is wrong. Cam2 is actually BEHIND the main layer so it's hidden. Move the main layer up by using the green arrow. Then deactivate Cam2 (the check sign to the left of Cam2) and try again.
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 09:35:26 PM
Yeah but then actor get invisible. Like covered by the background image
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 09:40:57 PM
It shouldn't be like that. How about if you ziped some minimalistic project and send it to me? It's really a guesswork right now as it should work and you probably just do multiple things wrong. PM me a link and I'll help you more easily. 
Title: Re: How does Scene.GetLayer works?
Post by: Mnemonic on September 26, 2012, 09:48:28 PM
If the two camera views are very different, consider using two separate scenes. They can share the same geometry. WME Demo 3D does that as well.
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 09:53:38 PM
Sounds awesome metamorphium!

Yes, Mnemonic, I know there's another way. It's just that the scene is suppose to be crowded with actors.
It's gonna be a huge pain to spawn them all in each scene
Title: Re: How does Scene.GetLayer works?
Post by: metamorphium on September 26, 2012, 10:20:31 PM
Ah! I see what you are trying to do now.

It would indeed be better to use separate scene. However if zou insist on one scene, put this background not as a layer but as an entity to the main layer. Then switch it on through var ent = Scene.GetNode("club2"); ent.Active = true; Also don't forget to reposition actor with actor.SkipTo() to adjust to the new camera.
Title: Re: How does Scene.GetLayer works?
Post by: Yakuzza on September 26, 2012, 10:26:29 PM
That should do the trick for me.
Thanks again metamorphium!