Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Actor won't unload  (Read 2833 times)

0 Members and 1 Guest are viewing this topic.

goldenTouch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 26
    • View Profile
    • Spare Time Gaming
Actor won't unload
« on: January 18, 2008, 11:55:37 PM »

Hey,

I'm having some issues with the way variables are created in WME.
In one of my scenes, I have an actor called FleetSalesman (the variable name). When I leave the scene, and go to a different scene, the actor is still there. Same position, different room.

I have loaded the actor as a var (not global), and I'm unloading the object in the SceneShutdown method.
So why doesn't it go away?

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

// here comes the stuff which initializes the scene

actor.SkipTo(400, 400);
actor.Direction = DI_DOWN;
actor.Active = true;

var FleetSalesman = Game.LoadActor("actors\Fleet_Salesman\Fleet_Salesman.actor");
FleetSalesman.SkipTo(690, 449);
FleetSalesman.Direction = DI_LEFT;
FleetSalesman.Active = true;



////////////////////////////////////////////////////////////////////////////////
// scene state
global StateEXT_Portagul_TheBeach_Night;


// default values
if(StateEXT_Portagul_TheBeach_Night==null)
{
  StateEXT_Portagul_TheBeach_Night.Visited = false;
  // add scene states here
}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables


////////////////////////////////////////////////////////////////////////////////
if(!StateEXT_Portagul_TheBeach_Night.Visited)
{
  StateEXT_Portagul_TheBeach_Night.Visited = true;

  // this is our first visit in this scene...
}


on "SceneShutdown"
{
Game.UnloadObject("FleetSalesman");
}
Logged

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: Actor won't unload
« Reply #1 on: January 19, 2008, 02:00:14 AM »

maybe you can use Scene.LoadActor insted..
than the character is only loaded to the acual scene and automatically unloaded by leaving the scene ..

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Actor won't unload
« Reply #2 on: January 19, 2008, 08:20:47 AM »

Game.UnloadObject() expects a reference, not a name, i.e.:

Game.UnloadObject(FleetSalesman); // without the quotes

But, as Stucki said, using Scene.LoadActor() instead will only load the actor for the duration of a single scene and unload him automatically when the player leaves the scene.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

goldenTouch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 26
    • View Profile
    • Spare Time Gaming
Re: Actor won't unload
« Reply #3 on: January 19, 2008, 08:51:15 PM »

Thanks guys.
I think I need to stop working late.
All these error I keep making are simple things that should never be done.
Sometimes, I think I'm infected with a little bug myself...  ::slug
Logged
 

Page created in 0.121 seconds with 20 queries.