How to make a car fly

i am making a harry potter stile game for my I.T project and i have gotten really far i just really need a script for the flying car, the controls could be:
spacebar makes it go up when you let go you go down the forward key moves you forward and the sideways keys make you move sideways, i think it would be best if maybe the car should fly through rings and maybe like after 10 rings it gets harder and maybe 5 sets of rings, but if that is to hard maybe they just have to follow an object in the sky (hedwig)

You're going to have to learn some Unity script before you can make a script like that. It's not too difficult, but you have to know what you're doing. You need to know how to write a basic script first. Browse the scripting reference.

1 Answer

1

Give the car a rigidbody component. Then you need to code it. Won’t give a full script but I’ll tell you how to Add Force.

using UnityEngine;
using System.Collections;

public class forceTest : MonoBehaviour
{
	float force = .05f;
	
	void Update()
	{
		if(Input.GetKey(KeyCode.Space))
		{
		    rigidbody.AddForce(Vector3.up * force, ForceMode.Impulse);
		    rigidbody.useGravity = false;
		}
		else
		    rigidbody.useGravity = true;

		rigidbody.AddForce(Vector3.forward * Input.GetAxis("Vertical") * force, ForceMode.Impulse);
	}
}

You will also need some max height settings and such, but this will get you started with physics. Unity Script Reference - Rigidbody

thank you lots for the help but i have no idea how to script so i usually take ones from the internet but thanx a lot i will try to figure it out

I'd learn a bit about coding if you want to ever make a game, unless you end up finding a coder that will stick with you from start to finish...

It's really not that hard once you go through some tutorials.

sure thanx for ur time and effort

um i tried to use it but i am getting some compiler errors they are expected. Insert a semicolon at the end. Unexpected token: :. and expecting ), found ';'. i am very confused by these is their any idea you would understand them