Skip to content

Commit

Permalink
Naive navigation and fixed camera
Browse files Browse the repository at this point in the history
Click to move working and fixed iso camera.

Camera isn't actually isometric but that is the best description I have
for it without researching the real name.
  • Loading branch information
Krustal committed Apr 9, 2014
1 parent 7471fb6 commit 1415661
Show file tree
Hide file tree
Showing 140 changed files with 2,045 additions and 13 deletions.
Binary file removed Assets/New Terrain.asset
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Particles/magicParticle.prefab
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Prefabs/skeletonDark.prefab
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Prefabs/skeletonFresh.prefab
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Prefabs/skeletonMage.prefab
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Prefabs/skeletonNormal.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Prefabs/skeletonNormal.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions Assets/Scripts/ClickToMove.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using UnityEngine;
using System.Collections;

public class ClickToMove : MonoBehaviour {

public float speed;
public CharacterController controller;

public AnimationClip run;
public AnimationClip idle;

private Vector3 position;

// Use this for initialization
void Start () {
position = transform.position;
}

// Update is called once per frame
void Update () {
if(Input.GetMouseButton(0)) // left mouse button
{
// locate where the player clicked on the terrain
locatePosition();

}

// Move player to position
moveToPosition();
}

void locatePosition()
{
RaycastHit hit;
// cast ray from camera to mouse position.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if (Physics.Raycast(ray, out hit, 1000))
{
position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
Debug.Log(position);
}
}

void moveToPosition()
{
if (Vector3.Distance(transform.position, position) > 1)
{
Quaternion newRotation = Quaternion.LookRotation(position - transform.position, Vector3.forward);

newRotation.x = 0f;
newRotation.z = 0f;

transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * 10);
controller.SimpleMove(transform.forward * speed);

animation.CrossFade(run.name);
} else
{
animation.CrossFade(idle.name);
}
}
}
8 changes: 8 additions & 0 deletions Assets/Scripts/ClickToMove.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Assets/Scripts/IsoFollow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Horizontal Distance to the target is always fixed.
For every of those smoothed values we calculate the wanted value and the current value.
Then we smooth it using the Lerp function.
Then we apply the smoothed values to the transform's position.
*/

// The target we are following
var target : Transform;
// The distance in the x-z plane to the target
var distance = 10.0;
// the height we want the camera to be above the target
var height = 5.0;
// How much we
var heightDamping = 2.0;

// Place the script in the Camera-Control group in the component menu
@script AddComponentMenu("Camera-Control/Iso Follow")

function LateUpdate () {
// Early out if we don't have a target
if (!target)
return;

// Calculate the wanted height
var wantedHeight = target.position.y + height;

var currentHeight = transform.position.y;

// Damp the height
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);

// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.position;
transform.position -= Vector3.forward * distance;

// Set the height of the camera
transform.position.y = currentHeight;

// Always look at the target
transform.LookAt (target);
}
8 changes: 8 additions & 0 deletions Assets/Scripts/IsoFollow.js.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/ShowCase.unity
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/ShowCase.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment/Cloak.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment/Cloak/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment/Cloak/Textures.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions Assets/SkeletonData/Equipment/Cloak/Textures/Fire-Texture.jpg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/SkeletonData/Equipment/Cloak/cape.FBX
Binary file not shown.
74 changes: 74 additions & 0 deletions Assets/SkeletonData/Equipment/Cloak/cape.FBX.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment/Hat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/SkeletonData/Equipment/Hat/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/SkeletonData/Equipment/Hat/hatr-hat01.mat
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/SkeletonData/Equipment/Hat/hatr-hat01.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/SkeletonData/Equipment/Hat/hatr.FBX
Binary file not shown.
Loading

0 comments on commit 1415661

Please sign in to comment.