Say I wanted to make a grassy hill that you can drive a tank around on and shoot rocks. Here is how it would work for me.
I would go into Unity and select New Project from the menu. This makes a folder that contains your project. It has folders named Assets, Library and Temp. Assets is where you put your stuff. Unity puts it’s stuff in the other ones.
Then I would make the grassy hill. I go into Blender, model it and save it into my Assets folder. I get a grass texture, make sure it is the correct size in Photoshop and save it in the Assets folder. Then I can go back into Blender, load the texture and paste it onto my terrain model. This is how you will make models for your game, from terrain to tanks to trees to animated characters (animations cannot be imported from blender. Hopefully this will come soon). It might vary how you do it depending on your setup and how you work, but that is the general idea.
Now if I go back to Unity, I will see my terrain I have just created in the Assets View in the form of a blender model, a texture and a material. From there I can drag and drop it to the game scene. Once there it should show up with the texture already on it. It might not, but the most you will have to do is drag the texture from the Assets View onto the mesh in the Scene View. I can add a collider component to my mesh object for physics interaction by selecting it from the add component menu. I can also create a light object and tweak it to illuminate the grassy hill however I want.
Then if I make a cube with the Create Primitive menu and add a RigidBody Component like how I added the collider to my mesh and place the cube above the mesh using the transform handles in the Scene Veiw, when I run my game by pressing the Play button I will see the cube in the Game View fall down, hit the slope and bounce or roll down in a realistic fashion.
Now I go to blender, model and texture my tank and save it and the texture(s) to the Assets folder. I can drag the tank onto the grassy hill and see it there but getting it to drive around and shoot with a camera following it around will be a lot harder. I will have to write a script that gets input from the keyboard and mouse or joystick, checks if each tank tread is touching the ground and if it is, adds forces to the rigidbody of the tank depending on the input (turn, go forward, go backward etc) to make it move. To aim the turret I will rotate my turret objects depending on the mouse input. For projectiles I will make a script that moves the object it is attached to forward until it hits something, then it makes an explosion where it hit. I could create a copy of the projectile object at the end of the tank barrel whenever the mouse button is pressed.
Any script that you write can be attached to an object just like the other components and you can see it in the Inspector when you select the object it is on to tweak it’s public variables (wether they are colors, numbers strings or links to other objects/components, it doesn’t matter).
I can’t really tell you exactly how this would be done but I can show you some exampes of code I have written for Unity.
LookAtCamera.js
private var target : Transform;
target = Camera.main.transform;
function Update ()
{
if(target)
{
transform.LookAt(target);
}
}
TimedDelete.js
var emitTimeOut = 0.00;
var deleteTimeOut = 1.000;
var detachChildren = false;
if(emitTimeOut != 0) Invoke("StopNow", emitTimeOut);
Invoke("DestroyNow", deleteTimeOut);
function StopNow ()
{
particleEmitter.emit = false;
}
function DestroyNow ()
{
if (detachChildren) {
transform.DetachChildren ();
}
DestroyObject (gameObject);
}
Projectile.js:
var speed = 0.00;
var randomMovement = 0.00;
var gravity = 0.00;
var framesPerRay = 1;
var extraRayDistance = 0.00;
var damage = 0.00;
var explosion : GameObject;
var detachChildren = true;
private var bullet : GameObject;
bullet = transform.FindChild("Bullet").gameObject;
private var trail : GameObject;
trail = transform.FindChild("Trail").gameObject;
private var velocity : Vector3;
private var hit : RaycastHit;
private var frames = 0;
frames = framesPerRay;
velocity = transform.TransformDirection(Vector3.forward) * speed;
function Update ()
{
frames ++;
if(frames >= framesPerRay Physics.Raycast(transform.position, velocity, hit, (velocity.magnitude * framesPerRay * Time.deltaTime) + extraRayDistance))
{
frames = 0;
other = hit.collider.gameObject;
Detonate(other, hit.point, hit.normal);
}
velocity.y -= gravity * Time.deltaTime;
if(randomMovement != 0) velocity += Random.insideUnitSphere * randomMovement * Time.deltaTime;
transform.rotation = Quaternion.LookRotation(velocity);
transform.Translate (0, 0, velocity.magnitude * Time.deltaTime);
}
function Detonate (o : GameObject, p : Vector3, r : Vector3)
{
o.SendMessage("Damage", damage, SendMessageOptions.DontRequireReceiver);
if(explosion)
{
object = Instantiate(explosion, p, Quaternion.LookRotation (r, Vector3.up));
}
if(detachChildren) transform.DetachChildren ();
Destroy (gameObject);
}
edit : oops looks like there were a few posts made while I was writing this.