Outdoor swimming
- MeteoricDragon
- Posts: 141
- Joined: Mon Feb 12, 2018 8:23 pm
Outdoor swimming
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?
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Outdoor swimming
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.
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.
- TheLacus
- Posts: 1305
- Joined: Wed Sep 14, 2016 6:22 pm
Re: Outdoor swimming
I'm not aware of this helper, but i think you want the reverse of what i do to instantiate insects, specifically GetTileWorldPosition.
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Outdoor swimming
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:
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)
- MeteoricDragon
- Posts: 141
- Joined: Mon Feb 12, 2018 8:23 pm
Re: Outdoor swimming
Ok thanks, I will use that.
- MeteoricDragon
- Posts: 141
- Joined: Mon Feb 12, 2018 8:23 pm
Re: Outdoor swimming
@interkarma How do you think the Riding behavior should be when swimming outside?
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Outdoor swimming
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.
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.
- MeteoricDragon
- Posts: 141
- Joined: Mon Feb 12, 2018 8:23 pm
Re: Outdoor swimming
Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?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.
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Outdoor swimming
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.MeteoricDragon wrote: ↑Fri Jun 29, 2018 2:28 am Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?
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.
- MeteoricDragon
- Posts: 141
- Joined: Mon Feb 12, 2018 8:23 pm
Re: Outdoor swimming
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.Interkarma wrote: ↑Fri Jun 29, 2018 2:52 amI 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.MeteoricDragon wrote: ↑Fri Jun 29, 2018 2:28 am Sounds good to me, But what about height? Should the player be RidingHeight - SameAmountSubractedWhenInWaterOnFoot tall?
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.
fall_062.png