Collision question

Post » Fri May 27, 2011 9:04 pm

I'm looking for a little light on the subject of collision and the difference between collision on activators and statics.

I've placed a ferry in a mod I'm working on, and it works... sort of. The problem that causes me the most headaches is the fact that after the ferry (a small longboat) travels a failry short distance the collision vanishes, letting player and ferryman drop into the water through the boat.. IAside from an unplanned bath, it also makes it difficult to disembark on the ohher side when you get there. I put in scripted waterwalking as a workaround, but it's not terribly satisfactory.

So, my question is this... If I had place the script on a different object (say the ferryman for instance), would the static longboat keep it's collision?

I've also noticed that static objects placed in game by "PlaceAtPC" through script or console also lose their collision, and I was wondering if there is a fix for that.

Back to the ferry issue for a sec, the ferry does not cross any cell borders so that should not be an issue. Here is the script I'm using:

Begin FerryScriptshort controlvarshort doneshort NorthEndshort SouthEndfloat currXposfloat currYposfloat currZposfloat BDcurrXposfloat BDcurrYposfloat BDcurrZposfloat FMcurrXposfloat FMcurrYposfloat FMcurrZpos;global ferry01If ( done == 0 ) ;get initial co-ordinatews	set currXpos to ( GetPos, X )	set currYpos to ( GetPos,Y )	set currZpos to ( GetPos, Z )	set FMcurrXpos to ( GetPos, X )	set FMcurrYpos to ( GetPos, Y )	set FMcurrZpos to ( GetPos, Z )	set done to 1endIfIf ( currYpos <=  ( -30000 ) ) ;determine whether ferry is on North side or South side		set controlvar to 0		set NorthEnd to 1		set currypos to (-29999)		ReturnendIfIf ( currYpos >= -27330 )  ;determine whether ferry is on North side or South side		set controlvar to 0		set NorthEnd to 0		set currypos to (-27335)		ReturnendIfIf ( GetDistance, Player >=128 ) ;check to see if player is on or very near boat			"Player"->setwaterwalking 0endIfIf ( MenuMode == 1 )	ReturnendIfIf ( ferry01 == 1 )		;DisablePlayerControls On a second thought I disabled this, but I may add it back in if it seems to cause issues		set controlvar to 1endIfIf ( controlvar == 1 ) ;waterwalking is set because of collision issuesset ferry01 to 0"Player"->set BDcurrXpos to ( GetPos, X )"Player"->set BDcurrYpos to ( GetPos, Y )"Player"->set BDcurrZpos to ( GetPos, Z )"Player"->setwaterwalking 1"1HD_Ferryman_01"->setwaterwalking 1set controlvar to 2endIfIf ( controlvar == 2 )	If ( NorthEnd == 0 )  ;Move ferry et al		set currYpos to ( currYPos + (-2) )		set FMcurrYpos to ( FMcurrYpos + (-2) )		set BDcurrYpos to ( BDcurrYpos + (-2) )		set controlvar to 3	endIfendIfIf ( controlvar == 2 )	If ( NorthEnd == 1 )		set currYpos to ( currYPos + 2 )		set BDcurrYpos to ( BDcurrYpos + 2 )		set FMcurrYpos to ( FMcurrYpos +2 )		set controlvar to 3	endIf	endIfIf ( controlvar == 3 ) ;move player and ferryman	if ( GetPos, y != currypos)			SetPos, y, currypos			"1HD_Ferryman_01"->setPos, y, FMcurrYpos			"1HD_Ferryman_01"->setPos, x, FMcurrXpos			"Player"->SetPos, y, BDcurrYpos			set controlvar to 2		endIfendIfEnd FerryScript


EDIT:
Moderator , Sorry, I originally posted this in the construction set ( or at least I tried) but I keep getting an error about secure key does not match. When that happens, I have to leave the site entirely and return before I can get anything to post... Anyway, I grabbed the wrong forum when I got back., my bad.
User avatar
Dalia
 
Posts: 3488
Joined: Mon Oct 23, 2006 12:29 pm

Post » Fri May 27, 2011 9:01 am

I put in scripted waterwalking as a workaround, but it's not terribly satisfactory.
setwaterwalking/modwaterwalking is usually enough to give player/npc vertical collision so they not sink (see Madmax's ultimate galleon code and/or gondolier code in water life)
Horizontal collision between ferry/boat and shore, and especially other creatures is the real problem, if you use a static/activator you probably have to use complicated invisible NPC colliders like in ultimate galleon.
If you manage to use a creature as ferry/boat mesh things are simpler (water life gondolier is Arcimaestro Antares' gondolier creature, just slighty reworked to have player on rotation center).
I've also noticed that static objects placed in game by "PlaceAtPC" through script or console also lose their collision, and I was wondering if there is a fix for that.
You could try placeitem, disable, enable, they usually work for me.
Oh, and I just recalled master ManaUser should have a small mod very similar to your needs, http://webpages.charter.net/manauser/morrowind/ , I suggest you take a look at his fine code.
User avatar
Chloe Botham
 
Posts: 3537
Joined: Wed Aug 30, 2006 12:11 am

Post » Fri May 27, 2011 5:40 pm

setwaterwalking/modwaterwalking is usually enough to give player/npc vertical collision so they not sink (see Madmax's ultimate galleon code and/or gondolier code in water life)
Horizontal collision between ferry/boat and shore, and especially other creatures is the real problem, if you use a static/activator you probably have to use complicated invisible NPC colliders like in ultimate galleon.
If you manage to use a creature as ferry/boat mesh things are simpler (water life gondolier is Arcimaestro Antares' gondolier creature, just slighty reworked to have player on rotation center).You could try placeitem, disable, enable, they usually work for me.
Oh, and I just recalled master ManaUser should have a small mod very similar to your needs, http://webpages.charter.net/manauser/morrowind/ , I suggest you take a look at his fine code.

Thanks! Unfortunately, the Suran Ferry wasn't particularly helpful as it just uses travel markers and teleport rather than actually riding the ferry. His method of calling the ferryman is interesting though.

The advice oif place/disable/enable was terrific, and worked like a charm. I would never have thought of that on my own... thanks again.

If you use a creature as a gondola, how do you past the lack of animation groups?
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Fri May 27, 2011 3:30 pm

If you use a creature as a gondola, how do you past the lack of animation groups?
A premise: I'm no modeler, just a minimal nifskope/nible resource tweaker.
It depends on the mesh... I've found that if the mesh you are using has at least a idle animation, using aiwander to play the idle often works.
Maybe also using something to catch and reset combat state, for instance
if ( GetTarget "player" )    stopcombatendif
(oops, by the way, I just realized I should add the stopcombat part to water life gondoliers, in case someone would want to role-play the evil gondolier killer, at present the results are... weird :facepalm: ).

Another example, the gondolier mesh works well enough for collision with other creatures/the player as passenger, but it does not detect collision with shore in time, so in that case I check for Z position against water level (0 in exteriors). As there is only 1 idle and it looks weird on the shore, I freeze with setparalysis until player is looking elsewere, then disable, a sort of compromise.

Creatures would have definite advantages over activators/statics if you have to do big movements (ships) between cells (no need to disable/setdelete/recreate on cell changes) and to detect collision with other creatures/npc,
problem is transport meshes with proper idle/collision to be useable as creatures are a scarce resource.

In your case, as the needed movement is short and fixed, probably collision detection with other creatures is not so important, and a static/activator with waterwaking/disable/enable is a better compromise.
User avatar
Floor Punch
 
Posts: 3568
Joined: Tue May 29, 2007 7:18 am

Post » Fri May 27, 2011 5:59 am

A premise: I'm no modeler, just a minimal nifskope/nible resource tweaker.
It depends on the mesh... I've found that if the mesh you are using has at least a idle animation, using aiwander to play the idle often works.
Maybe also using something to catch and reset combat state, for instance
if ( GetTarget "player" )    stopcombatendif
(oops, by the way, I just realized I should add the stopcombat part to water life gondoliers, in case someone would want to role-play the evil gondolier killer, at present the results are... weird :facepalm: ).

Another example, the gondolier mesh works well enough for collision with other creatures/the player as passenger, but it does not detect collision with shore in time, so in that case I check for Z position against water level (0 in exteriors). As there is only 1 idle and it looks weird on the shore, I freeze with setparalysis until player is looking elsewere, then disable, a sort of compromise.

Creatures would have definite advantages over activators/statics if you have to do big movements (ships) between cells (no need to disable/setdelete/recreate on cell changes) and to detect collision with other creatures/npc,
problem is transport meshes with proper idle/collision to be useable as creatures are a scarce resource.

In your case, as the needed movement is short and fixed, probably collision detection with other creatures is not so important, and a static/activator with waterwaking/disable/enable is a better compromise.


Theoretically, you could import a mesh into blender and create a basic idle animation that actually does nothing, then set that idle at 100 in AI Wander, right? Oh, and you mentioned setparalysis, does thatwork the same as a scripted "skip animation"?

Well, anyway, my ferry works as is, just not optimally so I think I'll just keep it and tweak it a bit. I was curious though as to why the collision works for oh, 512 to 1024 game units before vanishing. Thanks for all your input.
User avatar
rae.x
 
Posts: 3326
Joined: Wed Jun 14, 2006 2:13 pm

Post » Fri May 27, 2011 9:44 am

MWSFD suggests respawning it every few.
User avatar
patricia kris
 
Posts: 3348
Joined: Tue Feb 13, 2007 5:49 am

Post » Fri May 27, 2011 7:07 pm

MWSFD suggests respawning it every few.


do you mean disable/setdelete/recreate it as you would when making cell changes? I'm not really familiar with how to do that. Could you tell me what section to look in MWSFD to find it? I think maybe I have an old copy, I haven't seen it in there.
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Fri May 27, 2011 6:22 am

For anyone who might be doing anything similar, it turned out all I had to do was put in a disable and enable once each frame to keep collision intact. I didn't have to delete it or recreate it since I never came close to changing cells.
User avatar
Dark Mogul
 
Posts: 3438
Joined: Tue Feb 20, 2007 11:51 am


Return to III - Morrowind