Help with collision and Statics moving with Papyrus.

Post » Fri Nov 16, 2012 9:31 pm

I'm going to make this short and sweet. What I'm doing is trying to trap the player underwater with a large array of 'NordicMetalGrateX01' references. I need the grates to visually move in real-time while also maintaining collision. My brother made me a script but It went missing so I don't know what functions he used or anything. The last successful run we had left us with a script that lowered all the grates at the same rate; however, the grates lacked the collision to push the player down.

If anyone could provide me with a sample script (for those feeling super generous) or just some information about handling collision with Papyrus driven moving statics it would be greatly appreciated.
User avatar
Invasion's
 
Posts: 3546
Joined: Fri Aug 18, 2006 6:09 pm

Post » Sat Nov 17, 2012 7:00 am

There are some threads devoted to this very topic. The short-short version is:

1) Statics can't be Translated.
2) Activators using a NIF from a Static object can be Translated but their collision doesn't move with them unless you use MoveTo, which defeats the purpose of Translating.
3) You can, relatively easily, modify a Static NIF using nifscope to allow it to move its collision around when translated.

Here's the quick-n-dirty for point 3:
In order for regular collisions to work with TranslateTo, you must edit the bhkRigidBody settings in NifSkope to change:

Layer:
Change OL_STATIC to OL_ANIM_STATIC.

Layer Copy:
Change OL_STATIC to OL_ANIM_STATIC.

Motion System:
Change MO_SYS_BOX_STABILIZED to MO_SYS_BOX.

Phinix recommends using MovableStatics for these translatable objects; I prefer to use Activators. Either way, you're probably going to need to make the above changes in nifscope before you can make what you're working on behave as you intend.

Here's the context for this:
http://www.gamesas.com/topic/1383367-getting-collisions-to-move-with-translateto/
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Fri Nov 16, 2012 11:06 pm

I agree with Verteiron on all points... I've been using it my ship mod for a while now (translatingTo a bunch of Activators, which have the above changes to the NIFs). Here's a fairly recent thread which goes into more detail - http://www.gamesas.com/topic/1383367-getting-collisions-to-move-with-translateto/. One thing you need to keep in mind, it should work for Player while User is controlling it.. but an actor in the middle of its OWN translateTo function does NOT detect collision of any type except land.

As for the scripting; that depends if you want that stuff to move along with Player, be controlled remotely (by an actor/Player), or move by a pre-determined path/speed. If the last one, you can just set up an xMark and transToRef. The first is next easiest as it doesn't really require extra scripting for controls; but may need some formulas to calculate offsets.

Controlling movement remotely or by Player/User is the most elaborate, but can easily be done... though it doesn't sound like that's what you want (you should thank the stars if that's the case heheheh). But simple Pythagorian Theorum is what I use to calculate offsets for everything (except the transToRef of course). There's a couple ways PythTheor can be applied to achieve the same results.

Here's an actual snippet from my upcoming update to my mannequin mod (spodum); and is derived from my ship mod actually. This moves an object (in a separate event) using these calculations; the outcome is a mannequin that one may 'pick up' (not the 'grab' thing, though it looks like that kinda effect) and move/rotate along with Player's movements automatically to precisely place or reposition it ('dropped' by attacking it).
Spoiler

   PythX = Playa.getPositionX()	PythY = Playa.getPositionY()	PythZ = Playa.getPositionZ()	PythAng = Playa.getAngleZ()	if PythAng < 0.0							; keeps the primary angle between 0 and 360		PythAng = (PythAng + 360.0)	elseif PythAng > 360.0		PythAng = (PythAng - 360.0)	endif	float PythSin = math.sin(PythAng)	PythOpp = 100.0 * PythSin	if PythOpp != 0.0							; calculates adjacent		PythAdj = 10000.0 - (PythOpp * PythOpp)		PythRAdj = math.sqrt(PythAdj)	else		PythRAdj = 0.0	endif	if PythAng < 90.0						; moving NE		PythX = PythX + PythOpp		PythY = PythY + PythRAdj	elseif PythAng < 180.0					; moving SE		PythX = PythX + PythOpp		PythY = PythY - PythRAdj	elseif PythAng < 270.0					; moving SW		PythX = PythX + PythOpp		PythY = PythY - PythRAdj	elseif PythAng < 360.0					; moving NW		PythX = PythX + PythOpp		PythY = PythY + PythRAdj	endif
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Sat Nov 17, 2012 10:11 am

Thanks for your help. Ill give those a try once my bigger problem is rectified.
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm


Return to V - Skyrim