I am new to Unity and just downloaded the Unity free version.
I am wanting to create a space 3d sim, and I have played around with the FPS controller that comes with it.
Though I am having a problem with it. When I setup my space scene (skybox, sphere and point light) apply the FPS controller, it doesn’t work and am unable to “move” in the scene.
I have not changed anything in the script, in the Inspector panel of the FPS controller I have changed the speed to 25 and the gravity to zero.
Can anyone help me with this? What am I doing wrong? Thanks in advance…
I’m interested in this as well.
The FPS Cotroler Prefab does not move when it’s falling. If you set gravity to zero, you are falling you just don’t get anywhere.
You could change this in the Prefab but it’s still not very fitting for a Flight-thing. Better make your own.
Go to: Help / Scripting Manual and search for translate and for rotate.
i made a script for moveing around in space needs some work but it allows you to thrust and brake useing keys as i have gotten nowhere with mouse scrolling. it also allows you to turn. its a base script some of which i borrowed from others but your welcome to it.
var flyingSpeed = 0;
var minThrust : float= 0;
var maxThrust : float = 1000;
var Accel = maxThrust / 4;
var turnSpeed = 10;
function Update () {
//Accelerate the ship useing the thrust button.
if(Input.GetButton("Thrust")){
flyingSpeed = Accel + Mathf.Clamp(flyingSpeed, minThrust, maxThrust - Accel);
}
//decelerates the ship till stop.
if (Input.GetButton("Decellerate")){
flyingSpeed = -Accel + Mathf.Clamp(flyingSpeed, minThrust +Accel, maxThrust );}
if(("Thrust")){
rigidbody.velocity = transform.forward * Time.deltaTime * flyingSpeed; //Apply velocity in Update()
// Turning commands.
if(Input.GetAxis("Horizontal") > 0.0){ //if the right arrow is pressed
transform.Rotate(0.0, turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //and then turn the plane
}
if(Input.GetAxis("Horizontal") < 0.0){ //if the left arrow is pressed
transform.Rotate(0.0, -turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //The X-rotation turns the plane - the Z-rotation tilts it
}
if(Input.GetAxis("Vertical") > 0.0){ //if the up arrow is pressed
transform.Rotate(-20.0 * Time.deltaTime, 0.0, 0.0);
}
if(Input.GetAxis("Vertical") < 0.0){ //if the down arrow is pressed
transform.Rotate(20.0 * Time.deltaTime, 0.0, 0.0);
}
}
}
it needs some work as i said but its simple and will get you started.
This is great, thanks for this orindoomhammer. I do have one question though…how do I setup the thrust for it. It says that its not defined and as I said I’m new to this…so I don’t know how to define this…
yah just go in to Edit>project settings> input and pick a something your not really going to use maybe jump or something under name type Thrust then under positive button r or what ever button you think would be helpfull for you. and for decellerate do the same thing.
@orindoomhammer
Thanks a lot this is an awesome resource.
That’s a fine starting script you have there! It contains enough to get a beginner at least moving in a space sim.
yah i got some help with it. just enough to get me started in the right direction and i cant take credit for the stuff that makes you turn as i didnt write it. i just borrowed it. but it meshes well together.
i want to tidy it up make it more responsive and well make it move better. i am working on it so ill let you know when i get there.
I have to agree, with a couple edits I done last night, I must say…it worked!! Thanks so much.
Now I have to get the roll part of it too work, and the stopping on a dime not too happen, but it definitely got me going in the right direction.
Now I just have to brighten up my scene as its too dark so I can actually see where I am going…haha
yah if you are doing space flight i suggest makeing speed upwards to 1000 to 2000. this is space after all and things are not always close together so you need to go faster to get there. i am acctualy working on the roll right now. well sorta. im haveing pc problems. i very well maybe backing thing up today on my ehdd and nukeing my pc compleately. not something im looking forward to, but i may be nessasary.
Things happen, and sometimes it good to give the PC a good makeover…
I set my speed to 2000. When I get ready, I would like to figure out how to set an option for “warp,” that will adjust the 2000 to say 7000 or higher…but that of course is later.
Gotta get the roll to work first…start off small and work up. Like for example the HUD is something I still don’t know yet…
lol lucky you i a have already done that.
its abit tricky as it sticks instead of holding the button down and moveing fast then relaseing the button and slowing down. i am working on it. maybe soon as i get my pc to quit being retarded ill have it.
but here you go the updated script
var flyingSpeed = 0;
var minThrust : float= 0;
var maxThrust : float = 1000;
var Accel = maxThrust / 4;
var Jumpspeed = maxThrust * 5;
var turnSpeed = 10;
function Update () {
//Accelerate the ship useing the thrust button.
if(Input.GetButton("Thrust")){
flyingSpeed = Accel + Mathf.Clamp(flyingSpeed, minThrust, maxThrust - Accel);
}
//decelerates the ship till stop.
if (Input.GetButton("Decellerate")){
flyingSpeed = -Accel + Mathf.Clamp(flyingSpeed, minThrust +Accel, maxThrust );}
if(("Thrust")){
rigidbody.velocity = transform.forward * Time.deltaTime * flyingSpeed; //Apply velocity in Update()
}
if (Input.GetButton("Jump")){
flyingSpeed = Jumpspeed;
if(flyingSpeed < maxThrust){
flyingSpeed = maxThrust;}
}
// Turning commands.
if(Input.GetAxis("Horizontal") > 0.0){ //if the right arrow is pressed
transform.Rotate(0.0, turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //and then turn the plane
}
if(Input.GetAxis("Horizontal") < 0.0){ //if the left arrow is pressed
transform.Rotate(0.0, -turnSpeed * Time.deltaTime, 0.0 * Time.deltaTime, Space.World); //The X-rotation turns the plane - the Z-rotation tilts it
}
if(Input.GetAxis("Vertical") > 0.0){ //if the up arrow is pressed
transform.Rotate(-20.0 * Time.deltaTime, 0.0, 0.0);
}
if(Input.GetAxis("Vertical") < 0.0){ //if the down arrow is pressed
transform.Rotate(20.0 * Time.deltaTime, 0.0, 0.0);
}
}
as i said its not done im still tweaking it but it works lol. to slow down just hit the break.
Sweet, I will test this new script when I get home…looking forward too it.
yah the script is growing to a decent size. alas i think i may need to nuke the pc. keep haveing problems with it. so its time to start over. right now im just backing up files.
Good idea…
While I’m thinking about it…do you know of a good way to light the entire scene better? Right now i have one point light for a sun with a flare effect. But its so dark…
So when I go to implement the code you posted tonight, I can attempt to lighten the entire scene.
dont use the point light for big scenes use directonal lighting instead, put it where you want the sun you can give it a flare too. im still working out a way to get radial sunlight useing it though. so you dont need the sun outside the scene
Ah, ok…I will try that tonight as well…
so is it just you? or do you have a team? i have an idea how about some collaberation? im pretty sure were going for 2 differtn types of space sim. but maybe if your interested we could work together and develop both projects side by side. lending help here and there. personaly im more of a modeler then anything but im learning unityscript atm. if you would be intrested in working together who knows what could be possible. shoot me a pm with your game ideas you can find min in the showcase section along with some screens there very early and most of the assets you see will probly not make it in to the game.
Right now, actively we only have including myself, 3. There are 8 total and we are working from a forum I setup. Since three of them are on the otherside of the globe. Two in Denmark and another in Australia.
We were using PHP, MySql and Flash to do our game and go with a 2d isometric setup, until we heard about the release of Unity, so…needless to say, here we are.