Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Actor in region?  (Read 2901 times)

0 Members and 1 Guest are viewing this topic.

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Actor in region?
« on: February 07, 2005, 12:26:25 PM »

I need a Boolean expresion that contains True or False depending on whether an Actor is within a region.

What I need to achieve is to remove the "while (actor.X > StartX)" and replace with "while (actor.InRegion)" - or something similar...

In an ideal world - i'd also like the X coord extremities from the region variablised (thats not really a word is it?  ;) ) too - that way I dont need to specify the StartX and EndX variables at the top of the code - and thus making this little snippet of code completely portable throughout the rest of the project.

Any ideas?

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

var StartX = 320;      // Furthest left X coord of Region
var EndX = 640;       //  Furthest right X coord of Region
var MaxScale = -50;   //  The maximum complimentary scale to add to the standard scene scale

on "ActorEntry"   // When Actor Enters Region
{
  while (actor.X > StartX)   // Rudimentary "if In region" code...
  {
    actor.RelativeScale = (MaxScale /100) * ( (100 / (EndX - StartX)) * (actor.X - StartX) );  // Calculates the percentage to add to the current scale
    Sleep(10);  // Return control back to the engine
  }
}

on "ActorLeave"  // When Actor Leaves Region
{
  actor.RelativeScale = 0;  // Set Scaling back to default so as not to disrupt the normal scaling of the scene
}

Many thanks,
Kev

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Actor in region?
« Reply #1 on: February 07, 2005, 12:50:01 PM »

Hmm, well, the actor is in region whenever the ActorEntry even occurs. But I suppose you want him to be in region AND in a specified X coordinate range, right? You could define those StartX and EndX constants as custom properties in SceneEdit (select the region and click the "Custom..." button and add properties named StartX and StartY). That way you would be able to use the same script for all regions. The script would then read the custom properties simply by using "this.StartX" and "this.StartY".

Uff, does it make sense?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Actor in region?
« Reply #2 on: February 07, 2005, 01:01:34 PM »

Yes... that sounds like a good solution for portability purposes. I'll have a play with that code and see what I come up with.

Thanks again,
Logged
 

Page created in 0.018 seconds with 24 queries.