Outdoor swimming

Discuss coding questions, pull requests, and implementation details.
User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Outdoor swimming

Post by MeteoricDragon » Mon Jun 25, 2018 9:32 pm

I'm interested in Implementing outdoor swimming. You know, when you walk on top of a water tile you start swimming but aren't submerged. The kind that's not in dungeons. Can anyone share with me where I can find the code that evaluates what type of tile the player is standing on?

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Outdoor swimming

Post by Interkarma » Mon Jun 25, 2018 10:10 pm

I can see how this would fall into your wheelhouse since it's all about height adjustment and camera rocking effects.

I'm sure I put in a helper for this back when Uncanny_Valley was doing footprints in snow, but can't find it right now. The tilemap itself is in the DaggerfallTerrain the player is standing on. The basic idea is to convert their coordinate within the terrain to an index inside the tilemap.

I've got to run for work. Will take a closer look at this when I can and re-write helper if it's been lost somewhere along the way.

User avatar
TheLacus
Posts: 1102
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Outdoor swimming

Post by TheLacus » Tue Jun 26, 2018 7:01 pm

I'm not aware of this helper, but i think you want the reverse of what i do to instantiate insects, specifically GetTileWorldPosition.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Outdoor swimming

Post by Interkarma » Wed Jun 27, 2018 12:34 am

As this is something that will need to be continuously sampled, I've decided to build an efficient tilemap index sampler into StreamingWorld. This will keep track of whichever tile index player is aligned with from their X-Z position in world. Current tile index is updated every frame and available from property:

GameManager.Instance.StreamingWorld.PlayerTileMapIndex.

If the current PlayerTileMapIndex == 0 then player is standing on a full water tile (not an edge or corner tile). This would be an appropriate time to engage height change and camera rocking animations.

There are a total of 56 tile indices. See an archive like TEXTURE.302 to see what these map to. The common base indices are:

Code: Select all

-1 = Nothing/Error
 0 = Water
 1 = Dirt (snow in winter set)
 2 = Grass (snow in winter set)
 3 = Stone (snow in winter set)

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Outdoor swimming

Post by MeteoricDragon » Wed Jun 27, 2018 1:23 am

Ok thanks, I will use that.

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Outdoor swimming

Post by MeteoricDragon » Thu Jun 28, 2018 5:42 pm

@interkarma How do you think the Riding behavior should be when swimming outside?

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Outdoor swimming

Post by Interkarma » Thu Jun 28, 2018 9:50 pm

The horse is famous for moving at full speed through water in classic, but that just seems like a bug to me. I would rather have them move a bit slower as well. I've watched a lot of horses swim and they definitely don't move through water at top speed. It also makes water walking more special when it isn't basically available at any time by using the horse.

By the way, I'll add water walking effect asap so you can integrate that. It will just be a bool exposed by the player's entity class. You could use a dummy bool in the meantime while developing.

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Outdoor swimming

Post by MeteoricDragon » Fri Jun 29, 2018 2:28 am

Interkarma wrote:
Thu Jun 28, 2018 9:50 pm
The horse is famous for moving at full speed through water in classic, but that just seems like a bug to me. I would rather have them move a bit slower as well. I've watched a lot of horses swim and they definitely don't move through water at top speed. It also makes water walking more special when it isn't basically available at any time by using the horse.

By the way, I'll add water walking effect asap so you can integrate that. It will just be a bool exposed by the player's entity class. You could use a dummy bool in the meantime while developing.
Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Outdoor swimming

Post by Interkarma » Fri Jun 29, 2018 2:52 am

MeteoricDragon wrote:
Fri Jun 29, 2018 2:28 am
Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?
I think so, yeah, Just quickly checked classic and the player still sits higher in water on the horse. The amount subtracted from the starting height when in water always seems to be same.

This even seems to apply when player is crouched before entering water. Camera drops by the same amount relative to crouching head height and actually drops below ground level. That's obviously not so desirable. :lol:
fall_062.png
fall_062.png (16.44 KiB) Viewed 977 times

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Outdoor swimming

Post by MeteoricDragon » Fri Jun 29, 2018 3:59 am

Interkarma wrote:
Fri Jun 29, 2018 2:52 am
MeteoricDragon wrote:
Fri Jun 29, 2018 2:28 am
Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?
I think so, yeah, Just quickly checked classic and the player still sits higher in water on the horse. The amount subtracted from the starting height when in water always seems to be same.

This even seems to apply when player is crouched before entering water. Camera drops by the same amount relative to crouching head height and actually drops below ground level. That's obviously not so desirable. :lol:

fall_062.png
Right now I'm reworking the HeightChanger so that it adds to the controller height instead of setting it exactly. I am working around floating point error because adding floats causes it apparently. I'm doing it this way so that the water sink amount can be added independently of the other height amounts.

Post Reply