Author Topic: Andrew vs PHYSICS Round 42  (Read 2765 times)

0 Members and 2 Guests are viewing this topic.

Offline AndrewofDoom

  • In A.D. 2366 war was beginning
  • 29
  • Permanent yuri goggles.
    • Skype
    • Steam
    • Twitter
Andrew vs PHYSICS Round 42
So currently I'm having an issue with an dealing with ship-ship collisions in my super cool awesome rad mod I've been working on. Every time the player touches a ship, he'll skid along the surface. I know why this is happening. It's every frame I add to the player's velocity an equivalence speed to what the camera is scrolling at. Pretty scarey equation too to make it work. Take a look if you dare.

"So, Andrew, why exactly are you doing this?"

Why? I rather not do this to be honest, but certain...silliness about how FSO does collision detection. Originally, I had just moved the player's position every frame at the same rate as the axes scroll rates (everything else except the player that is slaved to the scrolling still does this actually). The issue comes when the player sits still and he is scrolled into a ship. Since neither the player or the ship he's about to run into do really have an actual velocity, the engine knows none of the better and pretends they aren't even intersecting, leading to ALPHA ONE becoming ETHEREAL ALPHA ONE.

Right, so enough rambling, I need some coming up with a way to deal with ship-ship collisions without causing the player to skid forward, become ethereal and noclip through the sucker, or as you'll see in the script I show down below, the player gets hurled forward moments later. This is the last physics issue I have that is wrt my script I made.

Here's the whole script. This one is an updated revision to fixes some other issues such as weapons and player being blocked by exploding ships. The speed adjustment related stuff begins on line 138 and ends with the Simulation hook.

I personally see only two options:

- Rewrite how collsion detection works. Like hell I can do that.
- Reduce the player hitbox for ship-ship collsions and kill the player instantly if he does collide. Because, hell, you'll be dead in levels where it is claustrophobic anyway.

I rather not do the second option, and I lack the skills to take on the first option.
My Efforts:
SF Knight

20:08:19   AndrewofDoom: Though I find it mildly disturbing that a loli is giggling to mass destruction.
20:10:01   Spoon: I find it mildly arrousing
20:10:07   AndrewofDoom: Woah
20:10:15   Spoon: sound like my kind of loli
20:10:21   Spoon: and im not even a lolicon

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: Andrew vs PHYSICS Round 42
Egad, you're doing everything by setting the position directly! Just use velocities instead and collision detection should work fine... or is that what you were doing when it was 'skidding'?

Or is my "just use velocities" assuming you're much better at math than you actually are?

  

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
Re: Andrew vs PHYSICS Round 42
Setting velocities results in collision skidding (it is really stupid - colliding itself works fine, it's what happens after)
Setting position results in no collision under certain circumstances.
(´・ω・`)
=============================================================

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Andrew vs PHYSICS Round 42
my problem with scripting a replacement physics engine for freespace is that there was no way that i knew of to turn off stock physics simulation. these days you can kinda hook into collision response now to do stuff, but you really cant turn off the stock response either. the game also has some new hard coded physics options, but these are likely to be just as limiting. this engine really isnt suited to a newtonian framework anyway so realistic physics are not possible. but you can kinda fudge it to make it satisfactory.

collision detection requires at least a frame's worth of physics state data history. why i exposed old velocity and old position (i think old orientation as well) to scripting. still that doesnt help much because you can set the velocity but fs is going to change it next time it runs its simulation code. you have to find a hook that runs right after that but before collision detection so you can replace freespace's values with your own. im not sure if such a hook exists.

my solution to the problem was to code a new game engine in lua standalone and port my physics scripts over (ive yet to do the latter and the former needs work). :D
« Last Edit: July 26, 2012, 03:39:50 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Andrew vs PHYSICS Round 42
The typical 'helpful' replies I see here!
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: Andrew vs PHYSICS Round 42
collision detection requires at least a frame's worth of physics state data history. why i exposed old velocity and old position (i think old orientation as well) to scripting. still that doesnt help much because you can set the velocity but fs is going to change it next time it runs its simulation code. you have to find a hook that runs right after that but before collision detection so you can replace freespace's values with your own. im not sure if such a hook exists.

Actually this part could be kinda helpful

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Andrew vs PHYSICS Round 42
i was more or less sharing my experience with physics mods. i eventually got stumped and gave up. thats not really all that helpful. i think i actually managed to get my ships and weapons to behave like i wanted, and the thing which ultimately doomed it was crashes on weapon impacts. i was simply pushing beyond the capabilities of freespace's numerical stability. you may want to poke through the atmospheric scripts there to see if you get any ideas.

I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline qazwsx

  • POST DRUNK GET TITLE
  • 29
Re: Andrew vs PHYSICS Round 42
Couldn't you just not add the scroll rate to the player when it's in contact with another ship?
« Last Edit: July 30, 2012, 10:43:52 am by qazwsx »
<Achillion> I mean, it's not like he's shoving the brain-goo in a usb slot and praying to kurzweil to bring the singularity

<dsockwell> idk about you guys but the reason i follow God's law is so I can get my rocks off in the afterlife

 

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
Re: Andrew vs PHYSICS Round 42
Couldn't you just not add the scroll rate to the player when it's in contact with another ship?

That might work... but it would have to be re-enabled when the player craft starts going off-screen. :P
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.