dim3 Forum

Full Version: Run Away Bot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How do you get a bot to run away from you? Ive made a script and everything in it is good except this:

Quote:function leitRunFromPlayer(obj)
{
obj.forwardSpeed.walk=35;
obj.motionVector.??????????;
obj.model.animation.start('Moving');
...
}

What should I define as motionVector?
That depends on what you want the bot to do.
"Run away from player" won't work (what direction?)
But you could make a spot (like behind a corner or something) that has the name "runawaySpot", (just an example) and use map.object.nearest(x,z,y,name,type,angle,angleSweep,minDist,maxDist); to return it's unique ID. Then make the bot move towards it.
I can't think of any other way to do this. :/
Couldn't you tell it to walk towards the player but assign a negative value for speed?
I don't think that assigning a negative value for speed will make the object go in the other direction. :/
It's worth a try though. :P
Do something like this:

Code:
// get the object ID of the player
var objectId=map.object.findPlayer();
// get the angle from you to the player
var ang=map.object.getAngleTo(objectId,obj.position.x,obj.position.z,obj.position.y);
// get the opposite angle
ang=utility.angle.add(ang,180);

Now you can just...

Code:
obj.angle.rotateTo(ang);

Then start moving.

[>] Brian
Good idea Brian, I will use that for Derek's spider.
I am very annoyed because I can't get the stupid spider to run away Sad.

---The negative value doesn't work, I've tried it.
ccccc Wrote:Good idea Brian, I will use that for Derek's spider.
I am very annoyed because I can't get the stupid spider to run away Sad.

---The negative value doesn't work, I've tried it.

The angle values have to be positive, 0 .... 360. The opposite is 180 away, so you can use utility.angle.add(myAngle,180); to get the opposite.

I'm going to post a couple scruffy scripts, it might help you and Derek along, I'll start a new thread for those, take a look later for them.

[>] Brian
ggaddwa Wrote:The angle values have to be positive, 0 .... 360. The opposite is 180 away, so you can use utility.angle.add(myAngle,180); to get the opposite.

dimwit Wrote:Couldn't you tell it to walk towards the player but assign a negative value for speed?

Wink
If I could look at some sidescroller scripts it would help me greatly. Derek (if he hasn't read this) probably thinks I'm not working on anything.

--Now I didn't during the second half of the IM contest because of time, but besides that I'm trying, but I'm not used to sidescroller AI Sad.
ccccc Wrote:If I could look at some sidescroller scripts it would help me greatly. Derek (if he hasn't read this) probably thinks I'm not working on anything.

--Now I didn't during the second half of the IM contest because of time, but besides that I'm trying, but I'm not used to sidescroller AI Sad.

I put one up now, it's in this subforum (scripting), check it out, it's a very simple mario-turtle like go back and forth script.

[>] Brian
Pages: 1 2
Reference URL's