Hi,
before starting It's important that we all know im noobish. Started using unity a few weeks ago for a project on my IMDesign degree and have little coding knowledge.
Ok so my problem is with SWIMMING in my water section. I have a rock type shore with a cave section under the water level. I would like for the user to be able to swim through the cave system as opposed to walking through it.
I am using the standard first person controller
After reading around these answers, videos etc, I am at the stage where I have:
Zero gravity under water by way of a box collider with the script found here attached.
This means that I float on the surface which is great. But I am unable to dive/swim down into the water!
this link allowed me to get as far as I have. I am stumped trying to code forwards movement in the absolute direction of camera
I thought the simplest way would be to grab the underwaterLevel position from this script
//This script enables underwater effects. Attach to main camera.
//Define variables
var underwaterLevel = 7;
//The scene's default fog settings
private var defaultFog = RenderSettings.fog;
private var defaultFogColor = RenderSettings.fogColor;
private var defaultFogDensity = RenderSettings.fogDensity;
private var defaultSkybox = RenderSettings.skybox;
var noSkybox : Material;
function Start () {
//Set the background color
camera.backgroundColor = Color (0, 0.4, 0.7, 1);
}
function Update () {
if (transform.position.y < underwaterLevel) {
RenderSettings.fog = true;
RenderSettings.fogColor = Color (0, 0, 0, 0);
RenderSettings.fogDensity = 0.02;
RenderSettings.skybox = noSkybox;
}
else {
RenderSettings.fog = defaultFog;
RenderSettings.fogColor = defaultFogColor;
RenderSettings.fogDensity = defaultFogDensity;
RenderSettings.skybox = defaultSkybox;
}
}
to determine when to switch the movement type? or grab something from the box collider that switches gravity off? Even still, I can't find the exact part of FPS motor script to modify..
Any help would be greatly appreciated as I'm totally confused :|
Sorry for the ramblings - i tend to do that.
Much thanks for reading,
Oli