Mircea Lobo Posted March 20, 2014 Share Posted March 20, 2014 I'm working on a slightly scifi themed sim (Opensim / OSGrid). Among many things, I wish to add bots that do various things. Scripting those things shouldn't be a problem, but I'm not sure how to script the bot movement itself.I don't need anything too fancy. What I basically want is a physical object that moves toward a random direction (choosing a new one every X seconds) and faces the direction of movement. If possible, I'd like the object to detect collosions and obstacles enough so it doesn't foolishly push into a wall until a new direction is triggered... though if that's too difficult I can live without it. It should however never try to go outside of the region's boundaries.No pathfinding please. Opensim doesn't have that and I'm not really a fan of it. llMoveToTarget might be a good candidate, and maybe llApplyImpulse can work too. Doubt llSetKeyframedMotion works for physical objects though.Note that I want the bots to also act as physical objects, so avatars or other physical objects can bump them. So the script must be aware that unforseen circumstances might change the position and rotation of the bot at any time, and still aim toward the same trajectory.Other than that, I'd like the script to be compatible with both air and ground bots. So I can make floating droids as well as wheeled / ground ones. In the case of flying bots, it would be a nice addition if a random direction could be chosen in all axes rather than just horizontally. Link to comment Share on other sites More sharing options...
Freya Mokusei Posted March 20, 2014 Share Posted March 20, 2014 Seems like this should be in the Wanted forum to me. At least, it doesn't seem like you're wanting help - you want someone to do this for you. How much are you willing to pay? Or willing to pay per hour of development time? I imagine that for OpenSim export, it'll need to be Full Perm? This tends to add quite a bit more to the cost, there might be additional costs to license such a script for use on other grids (specific or general) that aren't Second Life. Link to comment Share on other sites More sharing options...
Kayaker Magic Posted March 20, 2014 Share Posted March 20, 2014 On OpenSim, physics is an iffy proposistion. If this is a SIM that you are maintaining, you can use the new Bulletsim physics engine which is under active development and getting better. The old ODE physics engine is full of bugs and regularly crashes SIMs and nobody is working on fixing it. And even if the physics routines worked, llMoveToTarget doesn't move objects at a linear velocity, it moves them at a "critically damped" velocity, slowing down as it reaches the target. The only way to move a physical object at a constant velocity is to use the vehicle functions which are very complicated to use and even less likely to work well in OpenSim. You might consider instead using llSetKeyframedMotion (SKFM) wich has several advantages: It works on OpenSim 0.7.6, it moves non-physical objects, it moves objects at a linear speed, it doesn't require a debugged physics engine, and it is deterministic (unlike all physics engines, even the one in SL). SKFM accepts a list of delta positions, rotations, and times, but I usually call it with a list of one, then re-calculate the next position and call SKFM again. Sort of like llMoveToTarget but without the overhead and wierdness of physics. I published a script in the OSGrid Scripting Forum some time ago that impliments a simple flying critter. That was written before OS 0.7.6 came out and does not even use SKFM, but could be easily modified to do so. It could be modified to stick to the terrain surface, use llCastRay to try to avoid objects, etc. Link to comment Share on other sites More sharing options...
Mircea Lobo Posted March 20, 2014 Author Share Posted March 20, 2014 Bullet is now the default physics engine in Opensim, and what I use as well. It's working pretty nicely really. Other than that, I plan to have physical objects on my sim either way... such as crates and other stuff you can push around. So having bots be physical wouldn't be accidental or uinque, and I'd prefer it because it's more realistic. For example, shooting a small floating droid can push it back by a few meters. If I have to go with non-physical however, llSetKeyframedMotion indeed sounds like the best idea. And now that I know about the existence of llCastRay, a function to decide a trajectory would be even easier! Thanks for the info. Link to comment Share on other sites More sharing options...
Xiija Posted March 21, 2014 Share Posted March 21, 2014 As far as scripted movement, you could use something like this.... in your state entry.. llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE); in your timer ( this example is in a sensor and uses a target) pos = llGetPos(); vPosTarget = llDetectedPos(0); llSetStatus(STATUS_PHYSICS,FALSE); llRotLookAt( llRotBetween( <1.0, 0.0, 0.0>, llVecNorm( <vPosTarget.x, vPosTarget.y, pos.z> - pos ) ), 1.0, 0.5 );// face target llMoveToTarget( vPosTarget + <-1.0,-1.0,0.2>,3.50); // move to target with a little offset llSetStatus(STATUS_PHYSICS, TRUE); // set status after the move seems to work best? llSetTimerEvent(0.1); Link to comment Share on other sites More sharing options...
revochen Mayne Posted March 21, 2014 Share Posted March 21, 2014 Are you aware of the NPC functions openSim provides? I was playing with them some time ago on my own server and they seem to work well. They are atually avatars and you can move, animate, dress and let them talk by script. I was using pathway prims with certain commands within the description field and make the NPC/bot find them through a sensor. However this needs a custom configuration at the openSim.ini file. This article provides detailed informations: http://opensimulator.org/wiki/OSSLNPC Link to comment Share on other sites More sharing options...
Mircea Lobo Posted March 21, 2014 Author Share Posted March 21, 2014 Yes I am, and I totally plan to use the NPC function for scripted characters! With bots however, I prefer using primitives... since that gives me more control and they don't really need to be treated like real avatars (eg: Appear on the minimap). Link to comment Share on other sites More sharing options...
irihapeti Posted March 23, 2014 Share Posted March 23, 2014 i get what you are trying to do when I do this kind of stuff then I make a descrition list of what attributes the droids have. And what they are capable of. And as i scribble down my descriptions I note the language methods/functions that I will most likely need. I keep adding to my list until I pretty much got it all worked out before I do any scripting (my list pretty much turns into pcode by the time I got it all planned out). For example for starters: brainiac ( eyes: can see other objects to avoid collisions. Castray can move toward a distant targetpos. avoiding obstacles. around over/under on reaching targetpos then returns to homepos. on_rez (homepos = llGetPos) on reaching homepos then sets another distant targetpos to go to if obstacle is physical when droid has more mass then droid can push obstacle out the way. llSetForce or if droid has firepower then can blast obstacle to clear path. Rez object else droid navigates round obstacle (engine) ) status ( physical ) engine ( impulse: MoveToTarget primarily. if (targetpos > ? metres) ApplyImpulse to push in direction of targetpos torque: droid can move elliptically as well as in straight lines. SetTorque hover: droid can hover/bobble while brainiac is computing. SetBuoyancy SetHover ) etc etc + with droids I find that setting a distant goal for it to reach works better. Otherwise it acts more like a grazer which just wanders about without any goal. like sheep, chickens, etc Link to comment Share on other sites More sharing options...
LepreKhaun Posted March 24, 2014 Share Posted March 24, 2014 Wizardry and Steamworks has written a puppeteer framework for NPC's that you might find useful for this. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now