ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Objects react to collision? (Wishlist)
Objects react to collision? // Wishlistequin0xJan 15, 2005, 1:36am
I was wondering if it was possible to have a command to have some objects re
act to being touch/hit by another object, the best example would be a soccer ball. I'm not sure how it would work.. But if it was just for the one person to see (much like the activate move command), it shouldnt be all that hard. If it was to be done and show everyone, it would be quite harder, I would imagine. I think for few reasons, it should be a seperate special command itself, so people cannot misuse and abuse it in worlds like AW. jim1Jan 15, 2005, 5:53pm
[View Quote]
I think the bump trigger only works when the object is touched by an
avatar. To get an object to react to another object's touch, you might try a chain of animate (as a timer) action commands. There's an example of chained sign commands in AW at 20007N 7779E 270 (the scrolling sign). > If > it was to be done and show everyone, it would be quite harder, I would > imagine. I think a bot could do that, even if only by creating the reaction on the fly. kennethJan 15, 2005, 6:05pm
It would be nice if objects can use something like an If.. Then command like
in BASIC. For example: If tree8m.rwx = 15w 10n Then tree4m.rwx move 10 10 0 and you can have it so you can use any command besides move. You can also made a new command called collide or something and have: If tree8m.rwx collides with tree4m.rwx radius = .5 then ..... radius would be the area around each object in coordinates, that would need to get into range to set off the If / Then command. -Kenneth [View Quote] equin0xJan 15, 2005, 8:16pm
jim1Jan 16, 2005, 12:39am
[View Quote]
np. Well, then the bump trigger could at least initiate the process.
I'm unauthorised to use "move" in AW so I haven't played with it. The help at http://www.activeworlds.com/help/aw36/move_command.html says it "causes an object to move ... and then back again." It wouldn't seem natural for a soccer ball to bounce back to where it was kicked. No dice there. This is an interesting problem though. It might be generalised to avatars striking any object, like a cue ball or a baseball. Dreaming now ... a bot could find the angle of approach of the avatar with an arctangent function and even its velocity of approach with the AW_EVENT_AVATAR_CHANGE event (delta AW_AVATAR_Y and AW_AVATAR_Z/delta time) and then recreate the soccerball at its projected landing point using sine and cosine of the aforementioned approach angle multiplied by the impact velocity. (Lather, rinse, repeat, accordingly.) This seems an architype for other ball games. Has this been done already? Maybe in that bowling game? (I'm new here, haven't bowled yet. Sorry if this is too geeky.) > [View Quote] jim1Jan 16, 2005, 6:31pm
Just for kicks I made an object/object collision anyway. It switches
visibility off and on instead of using the move command. If anyone's curious, it's in AW at 20019.5N 7778E 90 . Click the green cylinder and it knocks the red cylinder away. I understand this doesn't resolve the original wish for an avatar-kick-object command but maybe this will help someone else peeking in on this thread. :-) [View Quote] sw chrisJan 17, 2005, 8:04pm
ubermonkeyJan 28, 2005, 3:33am
Okay, well, basically if you want reactive physics entities you have to
write some physics code and then link it to a bot's position in-world. The hardest part is that you're going to have to write the terrain, avatar, and object collision code for this object and know enough about the math and such to create at least semi-realistic reactions. Also, the object won't be able to roll very realistically in all directions since pitch only goes from -90 (facing up?!) to 90 (yes, facing down) degrees. My suggestion is that objects and avatars be treated as their bounding boxes (get this info from the registry), as writing a full per-triangle collision engine is not so easy (if it was, AWI might get around to refining the one in the browser a bit). Doing terrain collision is easy (I've got that code around here somewhere if anyone wants it, though it's really only useful as a "how to" since it relies on my PGC's internal data structures). Once you've got your collision code you encapsulate it, forget about it, and set up a simple method to handle collision events. Depending on the types and masses of objects involved, create the appropriate reaction forces. I'll get you started. while(!aw_wait(50)) { physEngine.collisionScan(); // execute the function that checks if any objects are colliding with other objects here. 20 frames per second. } Sorry, I have delusions of being witty, but anyway, it's not exactly a simple task if you want it to be realistic. If you want it to be only semi-realistic, then things are a little easier. Instead of writing a collision engine for all the objects, you could just use a distance check; if the ball is within 1m or so of an avatar or another ball it's considered to be in contact with it. Combine that with the terrain collision engine and you have a working system for playing soccer on terrain. Getting a little fancier, you could optionally set certain physics objects to stay only within a certain area (for example, the soccer ball hits an invisible wall if it tries to leave the defined soccer field area). You might then also want to place some collision beacons which link to specific scriptable events; in this case, goals. If you want realism without effort, you could pick up an open source physics engine (ODE I think it's called?) and link that up to your bot, though I don't know how hard that would be (probably rather hard). Suffice it to say, this *can* be done (it's much like those silly manually-flyable plane bots I had in Proxima), but it's really a task for an at least semi-experienced programmer. In order to actually be a playable game, server->bot lag would have to be removed by having both on one PC, and the avatar updates would have to be increased for more accuracy in collision detection (a little bot-side movement prediction a la most multiplayer games would also help here, and is easy to do; until new data has arrived from the server, assume the player is still moving at the same velocity it was). And there we have the physics in AW issue. If there's really interest in a little physics model bot to play with I might think about tossing something simple together and putting it up as open source, but it all depends on 1) interest, 2) has it been done already? and 3) my time constraints. If anyone cares, let me know and I might put together a soccer ball bot demo or something. -Monkies [View Quote] jim1Jan 29, 2005, 3:04pm
Fascinating stuff. Imagine orbiting bodies like a twin star or a
star-planet system. Crash your avatar into it, perturbing it, then you can stand back and watch the whole mess restabilize into new orbits! Also, virtual artillery! lol [View Quote] jim1Feb 28, 2005, 12:46am
At AW 20017N 7784E there's a curious example of one object appearing to
react to another which in turn reacts to the one. It's a pneumatic oscillator that could be manufactured in the real world. (If you spot the possible problem of a piston port connecting the wrong pressure lines, consider it could be solved by shifting the depth of alternate ports.) [View Quote] |