Compare commits
4 Commits
master
..
9c1ac2c040
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c1ac2c040 | |||
| 2668c0774e | |||
| 2d93071bfc | |||
| 521c86dbd4 |
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8ecf27f8ef94e904981b6ec7f5363702
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 140426efa0ba27942bd569222ed3a9f4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4b37e6f7170b25c4db6a0c78dfa46e57
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -423,7 +423,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 319279591}
|
m_GameObject: {fileID: 319279591}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -12.2, y: 1.51404, z: 15.37}
|
m_LocalPosition: {x: 9.4, y: 1.51404, z: 15.37}
|
||||||
m_LocalScale: {x: 2, y: 2, z: 2}
|
m_LocalScale: {x: 2, y: 2, z: 2}
|
||||||
m_ConstrainProportionsScale: 1
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -1023,9 +1023,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 9b9bab48a629093449f53dc5ea63d752, type: 3}
|
m_Script: {fileID: 11500000, guid: 9b9bab48a629093449f53dc5ea63d752, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::PlayerMove
|
m_EditorClassIdentifier: Assembly-CSharp::PlayerMove
|
||||||
|
basespeed: 8
|
||||||
speed: 8
|
speed: 8
|
||||||
rb: {fileID: 0}
|
speedincrease: 0.05
|
||||||
StartPos: {x: -15.5, y: 1.23, z: 12.73}
|
StartPos: {x: -15.5, y: 1.23, z: 12.73}
|
||||||
|
slide: 0.2
|
||||||
--- !u!1 &1262927943
|
--- !u!1 &1262927943
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PlayerMove : MonoBehaviour
|
public class PlayerMove : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[SerializeField] private float basespeed;
|
||||||
[SerializeField] private float speed;
|
[SerializeField] private float speed;
|
||||||
[SerializeField] private Rigidbody rb;
|
[SerializeField] private float speedincrease;
|
||||||
|
private Rigidbody rb;
|
||||||
[SerializeField] private Vector3 StartPos;
|
[SerializeField] private Vector3 StartPos;
|
||||||
|
[SerializeField] private float slide;
|
||||||
|
|
||||||
|
Vector3 moveDirection;
|
||||||
|
|
||||||
bool vertical;
|
bool vertical;
|
||||||
bool horizontal;
|
bool horizontal;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
@@ -21,26 +28,38 @@ public class PlayerMove : MonoBehaviour
|
|||||||
horizontalInput = Mathf.Round(horizontalInput);
|
horizontalInput = Mathf.Round(horizontalInput);
|
||||||
verticalInput = Mathf.Round(verticalInput);
|
verticalInput = Mathf.Round(verticalInput);
|
||||||
|
|
||||||
Vector3 moveDirection;
|
|
||||||
|
|
||||||
if (horizontalInput != 0 && horizontal == true)
|
if (horizontalInput != 0 && horizontal == true)
|
||||||
{
|
{
|
||||||
|
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||||
vertical = false;
|
vertical = false;
|
||||||
moveDirection = new Vector3(horizontalInput,0, 0);
|
moveDirection = new Vector3(horizontalInput,0, 0);
|
||||||
moveDirection.Normalize();
|
moveDirection.Normalize();
|
||||||
|
|
||||||
|
if (!vertical)
|
||||||
|
{
|
||||||
|
speed += speedincrease;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (verticalInput != 0 && vertical == true)
|
else if (verticalInput != 0 && vertical == true)
|
||||||
{
|
{
|
||||||
|
transform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
||||||
horizontal = false;
|
horizontal = false;
|
||||||
moveDirection = new Vector3(0, 0, verticalInput);
|
moveDirection = new Vector3(0, 0, verticalInput);
|
||||||
moveDirection.Normalize();
|
moveDirection.Normalize();
|
||||||
|
|
||||||
|
if (!horizontal)
|
||||||
|
{
|
||||||
|
speed += speedincrease;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moveDirection = new Vector3(0, 0, 0);
|
StartCoroutine(Slide(slide));
|
||||||
horizontal = true;
|
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||||
vertical = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,4 +71,14 @@ public class PlayerMove : MonoBehaviour
|
|||||||
{
|
{
|
||||||
this.transform.position = StartPos;
|
this.transform.position = StartPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerator Slide(float delay)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(delay);
|
||||||
|
moveDirection = new Vector3(0, 0, 0);
|
||||||
|
horizontal = true;
|
||||||
|
vertical = true;
|
||||||
|
speed = basespeed;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user