Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
formatting doesn't work on the screenshot comments so all spaces/tabulators are lost and code look like it's in sorry state...
Gladly programs generally automatically add them back, soo the code will look good after copy, paste, compile
It's just adding diving and nothing else, there is no balancing/whatever
You can stand on the ocean's floor and switch weapons there or regain stamina etc etc
Mobs can't dive, (code doesn't add it)
so either non-swimming one will wait for you at the ocean's floor
or swimming ones will wait at the water surface
Serpents wait at the surface.
During screenshot I lowered serpents a bit so they are underwater like me, but only cosmettically for screenshot, it's not in the code
Class: public class GameCamera : MonoBehaviour
Method: private void GetCameraPosition(float dt, out Vector3 pos, out Quaternion rot)
Delete those lines of code from method (don't need to add anything):
float waterLevel = WaterVolume.GetWaterLevel(vector3, 1f);
if (vector3.y < waterLevel + this.m_minWaterDistance)
{
vector3.y = waterLevel + this.m_minWaterDistance;
this.m_waterClipping = true;
}
else
{
this.m_waterClipping = false;}
Class: public class Character : MonoBehaviour, IDestructible, IWaterInteractable, Hoverable
Method: private void UpdateSwiming(float dt)
First remove this one line of code:
this.m_body.useGravity = true;
It's close to the bottom of method (under the code that you will be replacing)
float num2 = this.m_waterLevel - this.m_swimDepth;
if (base.transform.position.y < num2)
{
float t = Mathf.Clamp01((num2 - base.transform.position.y) / 2f);
float target = Mathf.Lerp(0f, 10f, t);
Vector3 velocity = this.m_body.velocity;
velocity.y = Mathf.MoveTowards(velocity.y, target, 50f * dt);
this.m_body.velocity = velocity;
}
else
{
float t2 = Mathf.Clamp01(-(num2 - base.transform.position.y) / 1f);
float num3 = Mathf.Lerp(0f, 10f, t2);
Vector3 velocity2 = this.m_body.velocity;
velocity2.y = Mathf.MoveTowards(velocity2.y, -num3, 30f * dt);
this.m_body.velocity = velocity2;}
With this:
if (this.IsPlayer())
{
if (ZInput.GetButton("Jump"))
{
Vector3 velocity = this.m_body.velocity;
velocity.y = 2f;
if (base.transform.position.y > this.m_waterLevel - this.m_swimDepth - 0.5f)
{
velocity.y = 0.5f;
}
this.m_body.velocity = velocity;
}
{
Vector3 velocity2 = this.m_body.velocity;
velocity2.y = -2f;
this.m_body.velocity = velocity2;
}
else
{
Vector3 velocity3 = this.m_body.velocity;
velocity3.y = 0f;
this.m_body.velocity = velocity3;
}
this.m_body.useGravity = false;
}
else
{
float num2 = this.m_waterLevel - this.m_swimDepth;
if (base.transform.position.y < num2)
{
float t = Mathf.Clamp01((num2 - base.transform.position.y) / 2f);
float target2 = Mathf.Lerp(0f, 10f, t);
Vector3 velocity4 = this.m_body.velocity;
velocity4.y = Mathf.MoveTowards(velocity4.y, target2, 50f * dt);
this.m_body.velocity = velocity4;
}
else
{
float t2 = Mathf.Clamp01(-(num2 - base.transform.position.y) / 1f);
float num3 = Mathf.Lerp(0f, 10f, t2);
Vector3 velocity5 = this.m_body.velocity;
velocity5.y = Mathf.MoveTowards(velocity5.y, -num3, 30f * dt);
this.m_body.velocity = velocity5;
}
this.m_body.useGravity = true;}
The weird "floating" thingies on the horizont is the water surface, to be precise, the waves