Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

Author Topic: How does Scene.GetLayer works?  (Read 8210 times)

0 Members and 1 Guest are viewing this topic.

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
How does Scene.GetLayer works?
« 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?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #1 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.)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #2 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
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #3 on: September 26, 2012, 08:05:40 PM »

oh. it's Unity. sorry about it.

Game.LOG, not Debug.Log
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #4 on: September 26, 2012, 08:49:36 PM »

it says [layer]
what am i doing wrong?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #5 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #6 on: September 26, 2012, 09:07:13 PM »

What i'm trying to do is simple really
Switch background image along with the gamera
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #7 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #8 on: September 26, 2012, 09:25:25 PM »

here you go


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
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #9 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #10 on: September 26, 2012, 09:35:26 PM »

Yeah but then actor get invisible. Like covered by the background image
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #11 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. 
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How does Scene.GetLayer works?
« Reply #12 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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: How does Scene.GetLayer works?
« Reply #13 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
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does Scene.GetLayer works?
« Reply #14 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
Pages: [1] 2  All
 

Page created in 0.036 seconds with 20 queries.