Getting collisions to move with TranslateTo

Post » Thu Jun 21, 2012 8:04 pm

So I have a really simple moving bridge with some scripting to have it TranslateTo it's opposite position when the player steps on it.

The problem is the object moves fine but it's collision data stays put, along with the player.

I've tried messing with collision import options on the parent object but those don't appear to do anything, at least as far as the collisions staying put. I also tried changing the BSX flag on the .NIF itself to 3, and several other settings, which just appear to make it either not have collisions at all or the game to crash.

I'm sure it is some simple super-secret flag hidden somewhere obvious, but looking at other moving collisions in the game I am at a loss to see where to enable this.

Perhaps it is more difficult than I imagine... Somewhere I read something about creating an invisible collision box around the player and moving that, but would you run into the same problem?
User avatar
Jessica Raven
 
Posts: 3409
Joined: Thu Dec 21, 2006 4:33 am

Post » Thu Jun 21, 2012 1:02 pm

I'm pretty sure there is no flag, and this is just the way the game engine works. My impression is that TranslateTo was only ever intended by Bethesda to be used in a very few specific situations, mostly involving actors. You might try;

1. Disable player controls and set player animation type to keyframed
2. Translate the player at the same time as you translate the bridge
3. When you've finished translating the bridge, either use MoveTo or SetPos to force the entire thing to it's final position
4. Re-enable player controls and re-set the animation type.

Or some other scheme for working around this issue.

If there is some way of just having TranslateTo work as expected, I'd love to know it :biggrin:!
User avatar
Alisha Clarke
 
Posts: 3461
Joined: Tue Jan 16, 2007 2:53 am

Post » Fri Jun 22, 2012 2:24 am

I ran into this with my Earth Prison mod. Each pillar is scripted to rise after being spawned below ground level, but then you could run right through them. I fixed it by doing as andyw suggested and using a MoveTo afterward, but this causes the objects to flicker in and out of visibility. I finally fixed it for good by spawning a duplicate, unscripted pillar in the exact same position as the scripted one, doing a MoveTo on the scripted one (the MoveTo fade-in was then hidden by the static, unscripted pillar), then deleting the "cover" pillars after a couple of seconds. This left me with each of my pillar activators in place with collisions and all scripting intact.

Major PITA, though, if anyone knows how to keep MoveTo or SetPosition from making the target fade in, I'd love to know how to do it.
User avatar
Lisha Boo
 
Posts: 3378
Joined: Fri Aug 18, 2006 2:56 pm

Post » Thu Jun 21, 2012 7:03 pm

There are some moveable statics that work fine with translateto type commands, doors are a goo example. If you made a bridge out of doors you mod will work fine.

In the case of statics not working OK, you can make the colision move to the current possition by disabling and then enabling the object.
User avatar
Louise Dennis
 
Posts: 3489
Joined: Fri Mar 02, 2007 9:23 pm

Post » Thu Jun 21, 2012 7:17 pm

Thanks for this post!! This explains the problem I see when I load NPC's on to a carriage. I call PlayIdle to have the passenger sit in their seat, Bethesda must be using a TranslateTo as their collision mesh is stuck at the carriage (0,0,0) position.

Anyone know more information on how animations work? It doesn't seem like I could change how the animation is being implemtned so I don't see that I could use a "moveto" instead?
User avatar
:)Colleenn
 
Posts: 3461
Joined: Thu Aug 31, 2006 9:03 am

Post » Thu Jun 21, 2012 9:44 pm

Tried it with a door, and had the same problem. Perhaps only certain doors? The one I chose was the animated door from inside the Bannered Mare.

If it had worked my next question was going to be what about the .NIF format was different from the static platform I was using. Would have loaded up NifScope to compare them. Since it did not work however, I am now considering implementing some sort of script trickery, setting up a loop that MoveTo's an invisible platform underneath the moving platform to the moving platform's current position every fraction of a second.

Since this is only going side to side (2-D), that should be sufficient for my needs this time around.

For 3D applications however this may be inadequate.

Imagine on a platform going up, the script uses moveto on the invisible platform the player is standing on, putting the place the player was standing just below the collision plane. The player would then fall through the platform!

Someone might say "well, just move the player then!" I thought of that. However, without going into too much detail, it will be fairly critical that the player be able to move around while on these moving platforms.
User avatar
Chris Cross Cabaret Man
 
Posts: 3301
Joined: Tue Jun 19, 2007 11:33 pm

Post » Thu Jun 21, 2012 9:09 pm

There is a major problem with setangle on the player and I would bet it will be the same for moving the player with functions like setpos.

Ambient sounds cuts out briefly. I was trying to use set angle z to force the player to mis bow shots and it works but each time the sound of the cave I was in would go silent then come back quickly. This is very distracting! This was not in Oblivion and is very probably going to be irritating for doing special set position effects on the player.


Someone might say "well, just move the player then!" I thought of that. However, without going into too much detail, it will be fairly critical that the player be able to move around while on these moving platforms.
User avatar
Taylor Bakos
 
Posts: 3408
Joined: Mon Jan 15, 2007 12:05 am

Post » Thu Jun 21, 2012 1:06 pm

Oh man, I had to do this ages ago, and I'm not sure I remember what I did.

Basically, you have to dive into the mesh and change it from being a "static" collision to being a "moveable static" collision. This setting is different than the "static" and "moveable static" object types in Creation Kit, this is actually stored in the .nif file.

IIRC, I had to use a program called "Nifskope" to extract the .nif file for the desired object from the skyrim .esm files, find the field that controls the collision type (sorry, I really do not remember the name of this at all, I learned which value to change by examining the stock "boat" objects, which are all moveable), then change the option. Save it under a new name. (I used the existing name but added "moveable" to the end.)

Now you can duplicate the Bridge static in Creation Kit, point the duplicate to your new .nif file, and your TranslateTo and MoveTo functions will work correctly, with collision.

I did this for my Paranoia mod on Steam Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=66907293

If you want to take a look at my modified .nif file (it's a statue at Meshes -> Dungeons -> Nordic -> ruinsdragonstatuemetal01) you can dig into my source control on Google Code: http://code.google.com/p/blakeyrats-skyrim-mods/source/browse/trunk/Data/Meshes/Dungeons/Nordic/

Hope this helps.
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Thu Jun 21, 2012 5:57 pm

Interesting. Also, funny idea for a mod! =P

I tried the ship in Windhelm docks, and also one of the little rowboats floating nearby, and neither of them work with TranslateTo. It seems MoveTo might work fine with collisions but TranslateTo does not?

I am also curious what the purpose of having http://www.creationkit.com/SplineTranslateTo_-_ObjectReference as a separate function available in the CK might be?

Possibly for calculating a modified trajectory when gravity is taken into consideration? (Or the projectile cam, to avoid jerky transitions?)

To be honest I hadn't really noticed whether ranged projectile kill cams follow the actual arc of the projectile, probably because it isn't noticable at the distance I get kill cams! =P
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Thu Jun 21, 2012 9:36 pm

Looks like it's the Layer Copy variable in the bhkRigidBody block. It's OL_STATIC for objects like pillars, but you've changed it to OL_ANIM_STATIC.

blakeyrat if this works you just saved me some MAJOR hassle. Thanks a ton!
User avatar
Svenja Hedrich
 
Posts: 3496
Joined: Mon Apr 23, 2007 3:18 pm

Post » Fri Jun 22, 2012 1:58 am

I can confirm setting OL_STATIC to OL_ANIM_STATIC on either/both the layer or layer copy of bhkRigidBody does nothing. Nor does converting bhkRigidBody to bhkRigidBodyT. I was sure the later would do it, since from the NifSkope documentation:

bhkRigidBody: This is the default body type for all "normal" usable and static world objects. The "T" suffix marks this body as active for translation and rotation, a normal bhkRigidBody ignores those properties. Because the properties are equal, a bhkRigidBody may be renamed into a bhkRigidBodyT and vice-versa.

My current thinking is this also requires changing the "Collision Response?" value (hkResponseType). It is RESPONSE_SIMPLE_CONTACT by default, and logic would seemingly dictate this would need to be changed to RESPONSE_REPORTING. However, again from the NifSkope docs this time for hkResponseType:

hkResponseType
Choices
Number Name Description
0 RESPONSE_INVALID Invalid Response
1 RESPONSE_SIMPLE_CONTACT Do normal collision resolution
2 RESPONSE_REPORTING No collision resolution is performed but listeners are called
3 RESPONSE_NONE Do nothing, ignore all the results.

So my understanding breaks down at the issue of "listeners." What are they, and where are they defined?

How are they used? Theoretically, these "listeners" could contain dynamically updated values of the offset coordinates of the TranslateTo command each cycle, but it could also have something to do with linked lists and I really have no idea where to read up on this for clarification.
User avatar
KIng James
 
Posts: 3499
Joined: Wed Sep 26, 2007 2:54 pm

Post » Thu Jun 21, 2012 4:42 pm

Sorry at this point all I can suggest is looking at the settings for the statue .nif I linked, since I know it works correctly.

I had a good summary of what I did to make it work in my notepad app at one point, but it's long since been deleted.
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am

Post » Thu Jun 21, 2012 7:59 pm

Sorry at this point all I can suggest is looking at the settings for the statue .nif I linked, since I know it works correctly.

I had a good summary of what I did to make it work in my notepad app at one point, but it's long since been deleted.

So you are using TranslateTo to move your statue, or MoveTo?

EDIT: I was able to confirm that set this works for TranslateTo, with clarification.

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.

Also, this may be obvious but the static itself must be created under MovableStatic in the CK, not the regular Static section.

Many thanks, blakeyrat!
User avatar
Jesus Sanchez
 
Posts: 3455
Joined: Sun Oct 21, 2007 11:15 am

Post » Thu Jun 21, 2012 12:00 pm

Sorry to hijack the thread, but Is there already a way to make custom collision?
User avatar
Jesus Duran
 
Posts: 3444
Joined: Wed Aug 15, 2007 12:16 am

Post » Thu Jun 21, 2012 3:45 pm

Custom Collision: not that I know of, unless you want some cheesy convex collision... but concave (eg: a wall with a window) - nope. Someone uploaded/linked some app to the NifTools forum, but I tried it and it crashed after taking its first breath.. so I never went further than that. I use collision boxes for certain things; for others I splice Vanilla collision into my meshes, then reposition/rotate them so they fit correctly (place it in its own bsFadeNode, then translate that node).

Moving objects' collision: I've been messing with this for months now... and I haven't found a way to do it as one would want. What I wound up doing was to make those objects Activators... activators' collision translatesTo. One thing you should be aware of (unless I've completely missed something)... transTo uses the absolute world X/Y axes for rotation, but the object's Z axis. So if you're trying to spin something while moving it - you'll have to do some crafty formula-driven scripting. You do NOT need to mess with the NIF file structure to finagle special collision types... it should work as-is.

Here's some other idiosyncrasies I found:
- Using havok collision in an Activator then trying to transTo it doesn't work... it just sits there motionless.
- TransTo also won't work on MiscItems (presumably the same reason.. the havok); setPos works though, but you get the fading/blinking like moveTo.
- You cannot transTo something that was enabled on the preceding line of code... you'll get a no3D error.
- You can't transTo a disabled object (no3D error).
- You CAN transTo an enabled Activator when it has no 3D... meaning you can do it from ANYWHERE at any time - as long as it was enabled (and a slight wait or other function afterwards).
- TransTo doesn't work on collision boxes (created in the renderWindow after hitting the 'box-C' button).
- You can moveTo any marker or box that has no 3D (such as trigger boxes and xMarkers).
- Doing a moveTo on a collision box (to simulate movement... since it's invisible it doesn't matter about the transTo) will push actors should they come in contact with them.
- TransTo an actor will render the actor's collision null - except the ground. It'll go through ALL other objects - statics, activators, actors, anything.

Hope this helps! It took me a lot of aggravation to finally get my ship sailing in real-time... with collision... and able to 'teleport' wherever and whenever I want.
User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Thu Jun 21, 2012 10:41 am

Good information here. Let's keep it going!

Next question (what I'm currently working on): How to have an activator placed ON a MovableStatic so that when it moves, that activator object moves with it!
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Thu Jun 21, 2012 6:04 pm

oooo... tough call, kinda. If you mean you want a havok object to travel on top of something, I haven't been able to do that. The collision will eventually fail and the object slides through the moving collision. It'll kind TRY to travel with it depending on the speed, but eventually - no. But if you mean getting two objects to move 'simultaneously' then YES... it's very possible.

Using transTo, I've been able to get three objects to move in close-enough synch. The fourth object would lag a little behind the first, as object zero (should there be one) would lag behind object three, etc. The key was to move things together that would be visibly noticed, should they be out of synch. Objects such as markers or collision boxes which are invisible can be done on the peripherals.

All in all, it mainly depends on the User's system and background interference (from other mods' scripts). I have a low-med level laptop I run Skyrim on; and those are my results. I've been able to stretch it to five objects, but that's with ZERO interference (no other mods at all) and running at as-low-as-it-goes detail settings... so that wasn't really an option for me. The game is just too horrible in super-low (mainly the distant LOD... not toooo bad on low, if all the LOD is max'd!).

I guess maybe you were asking how exactly to go about scripting that... it would be a matter of knowing where object one's origin and destination are, calculating the offset for object two and moving it accordingly. I found it easiest to have them at the same origin/destination - and adjust my custom meshes (in 3DSMax) so that they line up that way from the beginning.

I mentioned in another thread that I've started breaking up my code into multiple scripts to take advantage of multi-threading instead of being victimized by it. I have my movement in one, calculations in another, then poll Player's movement/controls in a third (for real-time sailing my Gokstad ship).
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am

Post » Thu Jun 21, 2012 5:25 pm

Exactly what I was thinking, SluckyD, regarding the simultaneous TranslateTo on all "attached" object's relative X, Y, Z position and offset. I guess I was sort of hoping there was a way to set up blank "links" in the Nif file itself that could be assigned dynamically via script in such a way as would handle this "child movement relative to parent" function internally.

I like the idea of breaking up scripts into threads, at least in theory. =)

EDIT: Something else I am running into trouble with is player motion relative to the moving object. It seems collision detection is sketchy. Sometimes the player moves along fine with the platform, but more often than not, they will sort of skip, sliding back along the platform, sometimes so much they slide right off!

I don't know if this is a friction sort of setting in the .NIF file or whether shorter intervals between TranslateTo commands would lessen the chance to nul, so that's what I'm testing ATM.
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Fri Jun 22, 2012 2:33 am

Come to think of it, I don't recall ever running into any moving platforms in my travels through Skyrim. I remember the animated Dwemer steam pistons, but they don't really do what I want to do.
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Thu Jun 21, 2012 7:57 pm

Moving objects' collision: I've been messing with this for months now... and I haven't found a way to do it as one would want. What I wound up doing was to make those objects Activators... activators' collision translatesTo.
Activators do not always collide during translate, it depends on the NIF. For Earth Prison, I used the NIF of one of the cave pillars, which by design is a Static, to create an Activator that I could translate (since Statics can't be translated at all). Collisions did not translate with the new activator and I had to use the rigamarole detailed in my earlier post to make them collide in their final, risen position. I'm willing to bet that the changes in the NIF that blakey and Phinix talked about will fix this, but I haven't had a chance to try it yet. Hopefully I'll have an opportunity this afternoon to test it out, but I can confirm that just making a NIF into an activator does not, by itself, create Translatable collisions.
User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Post » Thu Jun 21, 2012 5:27 pm

I've been contemplating the notion of a null motion field, basically a collision box around the platform that treats actors within it as though they were not moving while simultaneously maintaining their relative position within it.

I have tested linking up a created collision box to my main platform on the box's Attach Ref tab of it's Reference properties, and while this doesn't seem to work even with properly tweaked movable statics, it does with collision boxes.

The problem is, I haven't been able to find a collision layer that functions like that. It would be really awesome if such a thing were coded. I would really like to be able to jump any direction on a moving platform and travel the same distance relative to the platform/collision box around it.

Also, it seemed like it might be a way to get rid of the skippy, slippery collision translation of the player standing on the platform into something more seamless.
User avatar
Daddy Cool!
 
Posts: 3381
Joined: Tue Aug 21, 2007 5:34 pm

Post » Thu Jun 21, 2012 4:21 pm

Does anyone know a collision layer to set on my collision box's primitive tab that would "drag" the player along with it while inside?

I want to be able to move this collision box, and have inertia translate to the player while in the box. Basically, to make movement act like you were standing still while in the box.

So far everything I've tried seems to just spit the player right out. I don't know if I need to set it as a bounding box or if navmesh needs to be set a certain way, so I just thought I'd clarify what I'm attempting.

EDIT: More and more I am beginning to think there will need to be some more complex mathematical finagling to get what I want working...
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Thu Jun 21, 2012 2:23 pm

Just another update. I attempted creation of a perfectly horizontal invisible collision plane over the platform I am moving, such that the player is actually standing on this instead of the platform. The theory being, that at least part of the reason collision-based character moves using TranslateTo on the static they are standing on are so terribly choppy and bad, was because the platform I was using wasn't perfectly horizontal, meaning it was at an angle, so it made more sense the collisions might "slip" from time to time.

Sadly it turns out that collisions and thus, player character motion while standing on a Translating static, were just as choppy and slippy on a perfectly flat surface.

It seems to me actually, that TranslateTo as a whole is very resource unfriendly and bloated, and that the skipping I am seeing is more due to the engine getting backed up on position calculations even on my 4ghz machine than anything else.

I still have a dream of being able to create moving platforms that move at angles rather than just up and down or back and forth and have truly smooth motion translated to the player standing on them, without the slipping and clunkiness, but that dream seems farther away the more I work on it.
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Thu Jun 21, 2012 11:01 am

I don't know how to go about doing the thing about moving an actor inside something (as if it weren't moving)... but regarding the 'skipping' action, I do know some things.

It happens to me because the collision box I have underneath Player (presumably any actor though... I know horse act this way) isn't moving the same as Player itself. I have to moveTo the collision box (choppy movement, but invisible), while Player is transTo (smooth movement). Since the collision box is either not moving, but Player IS, or Player is between transTo functions and the collision box 'falls' out from underneath during its next moveTo.

The studdering action ('skipping') can be reduced so that it isn't so noticeable... and I actually like the effect it generates for my ship (since no real-life ship sails smooth as silk). But to do that; the script-timing, the movement speed, and the movement distance all need to be tweaked according to what you want. The object and the actor should be travelling the same speed though... any different and the studdering is exacerbated. Getting just objects to move smoothly is no problem, as is just an actor (I think... in Flyable Dragons mod, maybe the studdering is hidden by the flying anims)... it's getting both types to do it together was the biggest challenge.

I dunno if you've tried this yet or not, but cloning and altering one of the collision layers (COLL record) may help with the actor-in-a-box movement. You can try combining a navMesh layer with an actual collision layer... though somehow I doubt it'll work. I considered this myself, but never tried. I have successfully made a custom coll-layer though; that's what I now use as my 'crash-detection' (in lieu of my inivis-chicken I used to employ)... now the ship detects almost EVERYTHING (I disabled some stuff, like projectiles - as if an arrow could make a 75' ship stop! heheh).


I know that static collision (OL_Static in the NIF) works in activators... my Gokstad ship uses that (dock column collision). BUT - I haven't tested to see if that collision is actually collidable DURING the transTo... I only know that once the boat stops, the collision is where it should be; whereas it would left back at the orig script-start position should this be attempted with the SAME NIF used as a staticObject. Needless to say, I'll be testing this later today... heheh.

[EDIT: I haven't tried using my dock-column-collision technique underneath Player yet (well.. something flat of course, not the actual round column). Maybe having a transTo object (my activator) with its own collision would help with the studdering, since it would theoretically minimize or eliminate the aforementioned moveTo conflict. I guess that's TWO things I need to test later..]
User avatar
Tina Tupou
 
Posts: 3487
Joined: Fri Mar 09, 2007 4:37 pm

Post » Thu Jun 21, 2012 5:04 pm

Hey again, thanks for the input. I'll have to remember to check out your mod, it sounds cool. :smile:

The problem I am having is of course due to the fact I want the player to be able to move during transit. If not I would probably just TranslateTo on the player, and temporarily replace the ship with a duplicate with no collisions to move with them or MoveTo, so there was no chance of collisions causing stuttering.

The "collision field" was just an idea to make it so the player on the moving object wasn't effected by gravity, and inherited that object's inertia. Basically so that moving and jumping in any direction worked the same as if on the ground and stationary, not jumping way farther one way as it is now, but I have more or less given up on that being possible. It just doesn't seem to be within the native capacity of the engine, and the code that I would have to devise to to it, aside from being entirely theoretical with no working examples, would be incredibly complex even if it were.

I would be satisfied now just being able to move a platform with TranslateTo, and have the player move smoothly along with it.
User avatar
Kayla Bee
 
Posts: 3349
Joined: Fri Aug 24, 2007 5:34 pm

Next

Return to V - Skyrim