Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Player movement in Roguelike
  • Loading branch information
smz11006 committed Nov 17, 2015
1 parent d29b0b9 commit e196abb
Show file tree
Hide file tree
Showing 182 changed files with 41,913 additions and 13 deletions.
Binary file modified Roguelike/Assets/Scenes/EnemyAITest.unity
Binary file not shown.
19 changes: 16 additions & 3 deletions Roguelike/Assets/Scripts/EnemyZombie.cs
Expand Up @@ -2,14 +2,27 @@
using System.Collections; using System.Collections;


public class EnemyZombie : MonoBehaviour { public class EnemyZombie : MonoBehaviour {

public Ray ray;
public GameObject player;
// Use this for initialization // Use this for initialization
void Start () { void Start ()
{


} }


// Update is called once per frame // Update is called once per frame
void Update () { void Update ()
{
RaycastHit hit;
ray = new Ray(transform.position, Vector3.down);

if (Physics.Raycast(ray, out hit))
{
if(hit.collider.tag == "player")
{
transform.position = player.transform.position;
}
}


} }
} }
43 changes: 36 additions & 7 deletions Roguelike/Assets/Scripts/Player.cs
Expand Up @@ -3,13 +3,42 @@ using System.Collections;


public class Player : MonoBehaviour { public class Player : MonoBehaviour {


// Use this for initialization //Declaration
void Start () { public GameObject player;


} public float xPos;


public float zPos;
public Vector3 playerPos;
public float distance;

public Ray ray;
public RaycastHit hit;
public Vector3 travel;

// Update is called once per frame // Update is called once per frame
void Update () { void Update ()

{
xPos = Input.mousePosition.x;
zPos = Input.mousePosition.z;

ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if (Input.GetMouseButtonDown(1))
{
if (Physics.Raycast(ray, out hit))
{
travel = new Vector3(hit.point.x, .5f, hit.point.z);
xPos = hit.point.x;
zPos = hit.point.z;
}
playerPos = new Vector3(xPos, 0.5f, zPos);
iTween.MoveTo(gameObject, playerPos, distance);
distance = Vector3.Distance(travel, transform.position);

}
playerPos = new Vector3(xPos, 0.5f, zPos);

// player.transform.position = playerPos;
} }
} }
9 changes: 9 additions & 0 deletions Roguelike/Assets/iTweenEditor.meta

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

9 changes: 9 additions & 0 deletions Roguelike/Assets/iTweenEditor/Editor.meta

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

0 comments on commit e196abb

Please sign in to comment.