Commit 1d1cbe85 authored by Chae Ho Shin's avatar Chae Ho Shin

model working

parent b97055be
......@@ -26,13 +26,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8684657376034186961}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -15.01, y: 5, z: -1}
m_LocalScale: {x: 1, y: 0.5, z: 0}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!33 &8684657376034186972
MeshFilter:
m_ObjectHideFlags: 0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: e021c9db6b1e60c48b67f6a55624fdc3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,6 +13,10 @@ public class PathRenderer : MonoBehaviour
GameObject PathColliderPrefab;
[SerializeField]
Camera playercamera;
[SerializeField]
LevelManager levelManager;
[SerializeField]
GameObject background;
LineRenderer _pathRenderer;
float _originalPathColliderY;
......@@ -28,7 +32,7 @@ public class PathRenderer : MonoBehaviour
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(1))
if (Input.GetMouseButtonDown(1) && levelManager.player.isInertial())
{
RaycastHit hit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
......@@ -38,10 +42,17 @@ public class PathRenderer : MonoBehaviour
ray = playercamera.ViewportPointToRay(hit.textureCoord);
if (Physics.Raycast(ray, out hit))
{
// hit should now contain information about what was hit through secondCamera
if (Input.GetKey(KeyCode.LeftShift))
{
_DrawMorePath(hit.point);
}
else
{
_DrawOnePath(hit.point);
}
}
if (Physics.Raycast(ray, out hit))
}
/*if (Physics.Raycast(ray, out hit))
{
if (Input.GetKey(KeyCode.LeftShift))
{
......@@ -51,15 +62,15 @@ public class PathRenderer : MonoBehaviour
{
_DrawOnePath(hit.point);
}
}
}*/
}
}
private void _DrawOnePath(Vector3 point)
{
_ResetPaths();
square.pathList[0] = transform.position;
square.pathList[1] = point;
square.pathList[0] = transform.localPosition;
square.pathList[1] = transform.worldToLocalMatrix * point;
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(0);
}
......@@ -68,8 +79,8 @@ public class PathRenderer : MonoBehaviour
{
_pathRenderer.positionCount = 2;
square.pathList.Clear();
square.pathList.Add(transform.position);
square.pathList.Add(transform.position);
square.pathList.Add(transform.localPosition);
square.pathList.Add(transform.localPosition);
_pathRenderer.SetPositions(square.pathList.ToArray());
for (int i = 0; i < transform.childCount; i++)
{
......@@ -85,7 +96,7 @@ public class PathRenderer : MonoBehaviour
}
else
{
square.pathList.Add(point);
square.pathList.Add(transform.worldToLocalMatrix * point);
_pathRenderer.positionCount = square.pathList.Count();
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(square.pathList.Count() - 2);
......@@ -97,16 +108,16 @@ public class PathRenderer : MonoBehaviour
var _pathCollider = Instantiate(PathColliderPrefab, transform);
_pathCollider.name = "PathCollider-" + n;
_pathCollider.tag = "path";
_pathCollider.transform.localScale = new Vector3(2, _originalPathColliderY, 0);
_pathCollider.transform.eulerAngles = new Vector3(0, 0,
_pathCollider.transform.localScale = new Vector3(0.1f, _originalPathColliderY, 0);
_pathCollider.transform.localEulerAngles = new Vector3(90,
(float)Constants.RadianToDegree(Mathf.PI / 2 +
Mathf.Atan
(square.GetTangent(
square.GetNthPath(n)))));
square.GetNthPath(n)))) + 90, 0);
float _newY = square.GetNthPath(n).magnitude;
_pathCollider.transform.localScale = new Vector3(2, _newY * _originalPathColliderY, 0);
_pathCollider.transform.localScale = new Vector3(0.1f, _newY * _originalPathColliderY, 0);
_pathCollider.transform.position = (square.pathList[n] + square.pathList[n + 1]) / 2;
_pathCollider.transform.localPosition = (square.pathList[n] + square.pathList[n + 1]) / 2;
}
}
......@@ -13,6 +13,8 @@ public class PlayerMovement : MonoBehaviour
public Vector3 orientation = new Vector3(0.0f, 0.0f, 0.0f);
public double time = 0.0f;
bool isinertial = true;
int cnt = 0;
// Start is called before the first frame update
void Start()
......@@ -22,6 +24,7 @@ public class PlayerMovement : MonoBehaviour
cnt = 0;
orientation = new Vector3(0.0f, 0.0f, 1.0f);
time = 0.0f;
isinertial = true;
}
// Update is called once per frame
......@@ -79,4 +82,9 @@ public class PlayerMovement : MonoBehaviour
time += Time.fixedDeltaTime;
}
public bool isInertial()
{
return isinertial;
}
}
......@@ -18,7 +18,7 @@ public class Square : FlatLandObject
public float GetTangent(Vector3 v)
{
return v.y / v.x;
return v.x / v.z;
}
public Vector3 GetDestPoint(int n)
......
......@@ -12,10 +12,10 @@ public class UIManager : MonoBehaviour
public GameObject canvas;
public Text mytime;
public Planemovement clock1;
public Planemovement clock2;
public Text clock1time;
public Text clock2time;
//public Planemovement clock1;
//public Planemovement clock2;
//public Text clock1time;
//public Text clock2time;
public Text wintext;
public GameObject _pathUI;
public LevelManager Levelmanager;
......@@ -35,8 +35,8 @@ public class UIManager : MonoBehaviour
void Update()
{
mytime.text = Levelmanager.player.time.ToString() + " s";
clock1time.text = clock1.GetTime().ToString() + " s";
clock2time.text = clock2.GetTime().ToString() + " s";
//clock1time.text = clock1.GetTime().ToString() + " s";
//clock2time.text = clock2.GetTime().ToString() + " s";
if(Levelmanager.winstate)
{
wintext.gameObject.SetActive(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment