Code:
#pragma strict
function Start () {
}
var move : GameObject;
private var speed: float;
private var turnSpeed: float;
private var interaction: String; //interaction type
private var ship: String;
function Update () {
interaction = GameObject.Find("First Person Controller").GetComponent(Interactions).interaction; //Check interaction
speed = 100;
turnSpeed = 10;
ship = GameObject.Find("First Person Controller").GetComponent(Interactions).Helm;
move = GameObject.Find(ship);
if (Input.GetKey(KeyCode.W) && interaction == "Helm") {
move.rigidbody.AddForce(move.transform.forward * speed); // Add a forward motion onto it.
move.rigidbody.AddForce(transform.forward * speed);
}
}
I need help trying to move a ship (Sorry for some sloppy work, I haven’t clean it up yet).
Well, I can’t get it to work like I want to. I’m trying to get it to go forward from the ship front, but it doesn’t. Also I am trying to keep it on top of the water at the same time. Just won’t work like I want it to. I’ve done several things. Rigidbody won’t work for me. Cause everytime I put it on and I hit play, when the player get on the ship (he is dropped) the ship is repelled to the bottom of the ocean floor. So I lock the y position and it won’t, but when I do this I can’t move forward.
Can someone please help me with this problem.