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...


Author Topic: make an objekt come to the actor???  (Read 5389 times)

0 Members and 1 Guest are viewing this topic.

dorian

  • Guest
make an objekt come to the actor???
« on: December 23, 2003, 11:38:38 PM »

So here's a example:
1. Let's say my actor has got a vacum-cleaner und wants to get an objekt which is on the otherside of the river. Now I use the cleaner to "suck" the objekt to the actor. Is it possible that the objekt slowly "flys" to the cleaner and maybe scales down a little bit at the same time? I know its a funky example, but I don't have any other in my mind right now.

I hope you can answer my question.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:make an objekt come to the actor???
« Reply #1 on: December 24, 2003, 09:46:18 AM »

Hi, I made up this script:

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


////////////////////////////////////////////////////////////////////////////////
method MoveTo(TargetX, TargetY)
{
   var DeltaX, DeltaY, Step, StepX, StepY;
   
   DeltaX = TargetX - this.X;
   DeltaY = TargetY - this.Y;
   
   if(Math.Abs(DeltaX) > Math.Abs(DeltaY)) Step = Math.Abs(DeltaX);
   else Step = Math.Abs(DeltaY);
   
   StepX = DeltaX/Step;
   StepY = DeltaY/Step;
   
   for(var i=0; i<Step; i=i+1)
   {
      this.X = this.X + StepX;
      this.Y = this.Y + StepY;
      Sleep(10);
   }   
}


Copy this code to a .script file, and attach the script to your object. The object will now provide a MoveTo method. So, after the player uses the vacuum cleaner, just call:

object.MoveTo(SomeTargetX, SomeTargetY);

and the object should move slowly to the specified point. I hope that helps :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

dorian

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 2
  • I luv Wintamute!
    • View Profile
Re:make an objekt come to the actor???
« Reply #2 on: December 24, 2003, 11:50:36 AM »

Ahhhhh! Thanks a lot!   :) :) :)
Another Question: Do you (Mnemonic) write these scripts after you read the question or do you have them in a game already?? Because you allways answer damn quick!
« Last Edit: December 24, 2003, 11:55:42 AM by dorian »
Logged
Wintermute - Wintermut - Wintermu - Winterm - Winter - Winte - Wint - !! Win !!

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re:make an objekt come to the actor???
« Reply #3 on: December 24, 2003, 11:57:44 AM »

Another Question: Do you (Mnemonic) write these scripts after you read the question or do you have them in a game already?? Because you allways answer damn quick!

He is just a hero.  ;)
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:make an objekt come to the actor???
« Reply #4 on: December 24, 2003, 12:23:46 PM »

Hehe 8)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:make an objekt come to the actor???
« Reply #5 on: December 27, 2003, 02:58:29 PM »

Actually the truth is that Mnemonic is the Spiderman. :)

(Sorry for revealing your secret identity Mnemonic but I just couldn't resist.
Logged
fl*p

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:make an objekt come to the actor???
« Reply #6 on: December 27, 2003, 03:00:46 PM »

Hey, stop that! Or I'll reveal you're actually the matrix architect :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.042 seconds with 21 queries.