Hello, I am in great need for a script that is a 3rd person view and can drive/hover around in a map. It should be able to turn/rotate by following the position of the mouse (only side to side not up and down) and going forward, reverse, with "W" and "S" Here is a little preview. http://dl.dropbox.com/u/20233101/New folder/WebPlayer/WebPlayer.html And if its possible I am also in great need of a script for entering and exiting the ship. In return, if you help me with the script I will return the favor of some models that you need, or some art work, like textures (still learning GIMP though) Thank you, Wade
Anyone? I will also include your name in the credits of DA HUB as this is going to be a game option. Going to call the game "Little". if you want some models you can first view my work if you want: http://wademorrison.blogspot.com/ DA HUB's website (Little is going to be an in-game) http://www.dahubworldgame.webs.com/ This will be greatly appreciated!
Ok.... here's the script: Code (csharp): var speed : float = 4.0; var rotateSpeed : float = 3.0; function Update () { var controller : CharacterController = GetComponent(CharacterController); // Rotate around y - axis transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0); // Move forward / backward var forward : Vector3 = transform.TransformDirection(Vector3.forward); var curSpeed : float = speed * Input.GetAxis ("Vertical"); controller.Move(forward * curSpeed); } @script RequireComponent(CharacterController) Attach this to the ship, and you are good to go! Feel free to change the values at the top, they just change the speed.
Awesome! Thank you so much! Anything in return? And do you maybe know the script for entering and exiting the ship?
Hey! A mention of PhilliamApps in the credits is all I ask, and I'm working on a script that'll let you enter/exit ship. Also--- I saw your models, they're great! What program do you use, and how could I get a download of one of your structures?
Hmmm... Not to undo you Phillip, I had posted nearer what he needs in another thread. Though it was in 3d, you could always dump the z axis. http://forum.unity3d.com/threads/90493-smooth-problem?p=586976&viewfull=1#post586976 Honestly, it is the start and basis of the current project that I am working on. I hope it helps some.
My script is more simple, easier to modify... Not to put down your project lol. The script I posted is exactly what he wanted, I think he needed a script he didn't need to modify to suit his needs. Some times simple gets the job done.
I will mention you in the credits, as for the models just PM me and I will send whatever ones you want, but all I ask is to put me in the credits that you are using it for, and do not sell them.
Also, one little problem (or big not good with scripting) When I push W or S it does not move. But when I push A or D it just goes around in a circle. (around the x-axis not the y-axis) And the ship does not turn if I move the mouse.
wait.... is the script that I gave you working? is the glitching happening on my script or on BigMisterB's?
Heres the vehicle enter/exit script: Code (csharp): var car : Transform; var player : Transform; var exitPoint : Transform; var doorTriggerLeft : Transform; var PlayerCamera : Camera; var ShipCamera : Camera; var isPlayerVisible : boolean; function Update(){ if (Input.GetKeyUp("e") isPlayerVisible){ // make player invisible and still standing player.gameObject.SetActiveRecursively(false); player.gameObject.active = false; // parent player to Exit Point player.parent = exitPoint.transform; player.transform.localPosition = Vector3(-1.5,0,0); // parent PlayerParent to car exitPoint.parent = car.transform; exitPoint.transform.localPosition = Vector3(-0.5,0,0); // Enable Car as controllable object GameObject.Find("ship").GetComponent("ShipMove").enabled=true; PlayerCamera.enabled = false; CarCamera.enabled = true; } else { if (Input.GetKeyUp("x")){ // make character visible again --- this happens when the x button is pressed. player.gameObject.SetActiveRecursively(true); player.gameObject.active = true; // unparent player from everything player.transform.parent = null; // parent Exit Point to door Trigger-- the door trigger is the door to the ship, pretty much. exitPoint.parent = doorTriggerLeft.transform; // disable car as controllable-- making the player controllable GameObject.Find("ship").GetComponent("ShipMove").enabled=false; PlayerCamera.enabled = true; ShipCamera.enabled = false; } } } function OnTriggerEnter(Player : Collider) { isPlayerVisible = true; } function OnTriggerExit(Player : Collider) { isPlayerVisible = false; } You should change the "shipmove" to whatever you saved the first script as, and should change the "ship" to whatever you named the ship in your game. Then create a trigger for the door, and an exit point. After this, assign the trigger for the door and the exit point to the slots in the editor. This script should be attached to the ship. Hope this helps!
Big's is the one glitching out, but yours is working, but is only making me rotate around the x-axis if I push A or D. Why? Thank you for the scripts!
you can cast a ray from the main camera to the mousepoint on the screen, then get a point on that ray at a certain distance, then you can make your hovercraft LookAt that point's coordinates (this will rotate your hovercraft based on mouse movement) and for the WS controlls you can use the script Philip gave you to move forward or backwards, this part: Code (csharp): // Move forward / backward var forward : Vector3 = transform.TransformDirection(Vector3.forward); var curSpeed : float = speed * Input.GetAxis ("Vertical"); controller.Move(forward * curSpeed);