Jump to content
Sign in to follow this  
The_Captain

Setvelocity to a specific point... physics? (argh!

Recommended Posts

I knew I should have apid more attention in high school physics.

I need to write a script that keeps players within boundaries... and I'm annoyed with killing them.

The script would run client side, and find out if a player is in one trigger but not another (player in list *trigger && !(player in list trigger)), would then find the player's position, find the position of the map center (map is an oval), and calculate the vector to *probably* put the person back into the map (vehicle player, just in case), and set their velocity to that, then check again.

Is that all I should need to run this puppy? I'm gonna go give writing this a shot... I know 'm forgetting something =)

Idea is not to penalize players for missing the big warning signs, and instead make it impossible to travel outside. Also, if I get odd warping bugs and the player ends up some 500 odd meters from the mission (don't ask wink.gif ), I want the script to be able to oh so "gently" push them back in mission in about a second flat =D

I hope I'm thinking in the right direction...

Share this post


Link to post
Share on other sites

I could be wrong (hey it's happened), but my experiments lead me to believe that setVelocity is going to be a bit unreliable here because it doesn't work on the player as a soldier.

So I don't think it'll work, but let's say it did. All you'd do is take the position of the player and take the position of the centre of the map and subtract one from t'other. Then use the resulting 3D vector multiplied by some scalar as the argument for a setVelocity command. The scalar would effectively set your "speed".

Note that (to be absolutely proper about it) you'd need to find the absolute Z (height) coordinate of both the positions, rather than the height AGL. For the most accurate way of doing this, see my ProSphere scripts (shameless self-promotion, I know - but I don't care).

Prospero

Share this post


Link to post
Share on other sites

I like them scripts, prospero, just I haven't found a use for them in my mod/maps. Great work, though. If I ever need to put in a remote controlled drone...

(I was thinking of a remote controlled bomb-filled cessna for my terrorist side to use)

Also, I got the rest of the script working great... just... setvelocity does nothing to a player unit. =(

Setpos might work, but setpos is annoying, and I'm trying to bypass using it.

Share this post


Link to post
Share on other sites

It's your lucky day;) I've got it to work. And this also means you can make soldiers jump now. Edit: And do HALO-type stuff. Yep you can fire your gun as you fly through the air;)

The trick is to just raise the player into the air (by a tiny amount) using a setPos. Then use setVelocity on him BEFORE his height AGL falls back to 0. It'll now work.

I, quite frankly, rock.

Prospero

Edit: Ooooooh and jetpacks;) Me like.

Share this post


Link to post
Share on other sites

Oh, wow, crapola!

I used setpos, which "works", but I'll have to check out the velocity!

Thanks prospero!

...oh my god...

If you combine jumping with yoru multi-control interface, I can have jumping in Homeland Security.

AAARRRGGGGHHH

(When someone makes a mod along the lines of Counter-Strike, he is usually trying to get away from counter strike gameplay. Having bunny hopping g36 whores is not my idea of fun! argh!wink.gif

=D

Still, great solution.

Share this post


Link to post
Share on other sites

I´ve done that jumping thing for ages, it´s fun bodyslamming houses with tanks from a 1000 m. biggrin.gif or jumping up in a tree and snipe, just not very realistic though smile.gif

But the thing with the setvelocity i havent tried yet, could you perhaps post the script?

Share this post


Link to post
Share on other sites

If no-one else bothers, I'll post a (player soldier) jump script later this evening (jump using setVelocity). I want it to be bullet-proof before releasing it even if it is extremely simple.

Edit: (much later, whilst reading back on the thread) Why the hell did I say it was "extremely simple"? I'm such a fool! Shut your mouth Prospero and never darken my doors again.

Edit: In view of this, I'll also be adding an implementation of jump to ProSphere Lite in the upcoming (one week) non-BETA version. There are a couple of other useful features too. You can direct ProSphere to get the yaw, pitch and roll of any object and also the location (xyz) of an object in a specified vehicle's body frame coordinate system.

Further edit: Using ProSphere to jump allows you to use "aftertouch" - i.e. you have control whilst you're in the air. You can also twist whilst in the air, but I'm afraid you'll have to use keys X and C rather than the mouse. But actually.. this is better because you can't twist in real life - what's the view - do you want twist in the air or not?

Prospero

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ Nov. 01 2002,17:57)</td></tr><tr><td id="QUOTE">Cool thinking Prospero!  But what does AGL mean?  Angle??

Doolittle<span id='postcolor'>

AGL = Above Ground Level.

Prospero

Share this post


Link to post
Share on other sites

Good work Prospero... who would have thought that the Player was glued to the ground. biggrin.gif

Share this post


Link to post
Share on other sites

OK, I'm not going to post the simple jump script tonight because I want at least a day to test it fully. It's working very well, but there's just a couple of tiny things which I want to get perfect.

Plus I've had way too much Chardonnay;)

So, it'll be tomorrow night. Btw, I'm trying to make it as Quake-ish as possible, but as I've said, you'll need ProSphere to get "aftertouch" working.

Edit: I also want to decide on an appropriate height for the jump. I'm thinking one meter might be appropriate - if you time it right. I'd appreciate some feedback, because this might need an agreed "standardizing".

Prospero

Share this post


Link to post
Share on other sites

A low gravity multiplayer map would be fun, with people running around jumping...

No, wait, it wouldn't nescessarily be fun, but it would have novelty value. =D

Share this post


Link to post
Share on other sites
Guest

A possible solution that springs to mind (havn't tried it): Create a vehicle move the soldier into the vehicle. Use setvelocity on the vehicle and move the soldier out of it. Then delete the vehicle.

Perhaps an invisible o2 jump proxy vehicle could be created...

Share this post


Link to post
Share on other sites

Damn it. I may just have sussed a way to do the "aftertouch" with considerably less overhead than is currently used by my ProSphere thingy. Not sure, need to test.

Funny what one dreams about in bed.

Prospero

Share this post


Link to post
Share on other sites

On the jumping:

I'm just going through a bit of a inner colloquy;) The jump script needs to be able to sense if you're standing on an object to work properly, and how high the surface of the object on which you're standing is. It's not a big deal as I've got a couple of ways to do this, but it's taking a little longer than I expected, though I still hope to have it out tonight, and bullet-proof.

Funny (but yet totally logical) things happen with objects with Roadway LODs.

Edit: God, this is taking time. I think I've solved it - the problem has been allowing jumping off objects that DON'T have a Roadway LOD. This is going to take a little while longer, but as I say, I believe it's still on.

Prospero

Share this post


Link to post
Share on other sites

OK, it's possible, but it seems you'll have to use a tiny little add-on object. I'm trying to find a way of not using an add-on, but I suspect there is no other way.

Prospero

Share this post


Link to post
Share on other sites

Im not sure if I understood this thread correctly, but if you are just trying to be able to use setvelocity on a regular soldier, it works fine after you setpos him a bit to the air first. (for example do "player setpos[getpos player select 0,getpos player select 1, (getpos player select 2)+0.01};player setvelocity[100,100,100];" on a trigger)

Share this post


Link to post
Share on other sites

Yes, but it's a matter of getting a "jump" thing going. I.e. One must only allow a jump when one is actually in contact with a surface (Roadway LOD or no Roadway LOD). That's what's frying my brain at the mo;) Otherwise you can keep jumping until you're up to the stars!

wink.gif

My way of doing this (which is working, but not fully tested) is by using an add-on. I'm trying to find a better way.

Prospero

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Kegetys @ Nov. 03 2002,06:33)</td></tr><tr><td id="QUOTE">but if you are just trying to be able to use setvelocity on a regular soldier, it works fine after you setpos him a bit to the air first.<span id='postcolor'>

My own shit parrot fashion.

Cheeky.

Prospero

Edit: I think the (temporary) solution here is to do two versions of jump:

1) With this version, you can basically jump off anything with a Roadway LOD. This is simple and easy, and therefore 100% reliable and fast.

2) With this version, you can jump off objects whose surfaces are not Roadway LODs. The roof of a jeep would be an example. This is hard (at least, it is for me), and I can't do it 100% reliably. Yet.

"Aftertouch" is down to ProSphere in both cases, at least for now.

I'll post version 1 of the jump thing shortly. It will just be jump - no "aftertouch". Unless peeps want to do "aftertouch" themselves it'll be a matter of waiting for the non-BETA version of ProSphere.

Prospero

Edit: Hehehe I've got one version of jump where you can jump up and stick to walls. Very spiderman.

Share this post


Link to post
Share on other sites

Here's a rather nice consequence of my jump script - and completely unexpected.

I was experimenting with big jumps and using ProSphere to do "aftertouch", and found I can make it so you can walk round on roofs (without Roadway LODs) now without jerking about like one used to. I spose it's obvious in hindsight, but still...

Now I just need to be able to shoot webs.

Prospero

Share this post


Link to post
Share on other sites

I'm trying to make a jump action:

jump.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

s1 setpos [getpos s1 select 0,getpos s1 select 1, (getpos s1 select 2)+0.01];s1 setvelocity[6,6,5];

<span id='postcolor'>

And problem is he only jumps northeast. I think i know why, it's the 6,6 in the X,Y

How do I make the script get the current direction of the player and uses that for the vector?

Any help much appreciated.

Share this post


Link to post
Share on other sites

This is a sample from something I'm playing about with. It isn't supposed to be a working script, but you can extract from it what you want to do, Lt_Damage.

----------

PSg = "logic" camcreate [0, 0, 0]

#lp

_ps = PS

PSg setpos [(getpos player select 0), (getpos player select 1), 0]

PSd = PSg distance player

_dx = (cos(getdir player) * (_ps select 0) + sin(getdir player) * (_ps select 1))

_dy = (-sin(getdir player) * (_ps select 0) + cos(getdir player) * (_ps select 1))

?(PSd >= 0.05): player setvelocity [_dx * 5, _dy * 5, (velocity player select 2) - abs(_ps select 2) * (velocity player select 2) + 5 * (_ps select 2)]; player setdir getdir player + (_ps select 5) * 5

~0.0001

goto "lp"

----------

Share this post


Link to post
Share on other sites

An update:

One of the challenges has been to provide "aftertouch" consistently so that it works regardless of whether you've jumped off something or simply walked off the edge and are falling. This needed to work between levels of buildings as well as if you just walked off the roof of a single level building and fell to the floor.

It's coming. There's just one tiny little niggle left...

Edit: I've also got a jetpack mode. Don't suppose anyone has got a player model who looks like he's wearing a jetpack? (There's no need to "get into" a vehicle to do this. It can just be a special player model with a back-mounted jetpack thingy). Scratch that, I've thought of a much better way whereby the jetpack can be a proper pick-up-able secondary weapon, and used just like one. Hmmm seamless;)

Edit: Lobbing grenades down onto people from 100 feet is mucho funno. As is attempting to crap on them.

Edit: I think I can disable the ability to jump/jetpack if your legs are too damaged (i.e. when you can't stand up). Gotta try it...

Edit: OK, the jetpack thingy is a secondary weapon. I'm using key E to provide vertical thrust when in possession of it (you will still actually USE your primary weapon so you can shoot as you fly). This means you can't run in turbo mode whilst you have the jetpack - but the jetpack is of course heavy - so it really should slow you down a bit. A good compromise IMHO.

Prospero

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×