mirror of
https://github.com/Steffo99/keep-everything-alive.git
synced 2024-11-24 02:14:17 +00:00
Disallow cheesing
This commit is contained in:
parent
e34322cee5
commit
8b048637b1
2 changed files with 9 additions and 4 deletions
|
@ -318,6 +318,8 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 63616322c82d5e64e8e7199d51c6a2ef, type: 3}
|
m_Script: {fileID: 11500000, guid: 63616322c82d5e64e8e7199d51c6a2ef, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
min: {x: -8.5, y: -4.5}
|
||||||
|
max: {x: 8.5, y: 4.5}
|
||||||
--- !u!114 &446180029092811511
|
--- !u!114 &446180029092811511
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -330,7 +332,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 3942a3e38c32eed40bff470e6bbddf42, type: 3}
|
m_Script: {fileID: 11500000, guid: 3942a3e38c32eed40bff470e6bbddf42, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
activationDelay: 0.7
|
activationDelay: 0.4
|
||||||
--- !u!114 &446180029092811510
|
--- !u!114 &446180029092811510
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -344,4 +346,4 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
color: {r: 1, g: 0, b: 0, a: 1}
|
color: {r: 1, g: 0, b: 0, a: 1}
|
||||||
activationDelay: 0.7
|
activationDelay: 0.4
|
||||||
|
|
|
@ -5,6 +5,9 @@ using UnityEngine;
|
||||||
[RequireComponent(typeof(Rigidbody2D))]
|
[RequireComponent(typeof(Rigidbody2D))]
|
||||||
public class FollowMouse : MonoBehaviour
|
public class FollowMouse : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public Vector2 min;
|
||||||
|
public Vector2 max;
|
||||||
|
|
||||||
private new Rigidbody2D rigidbody2D;
|
private new Rigidbody2D rigidbody2D;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
|
@ -13,12 +16,12 @@ public class FollowMouse : MonoBehaviour
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
Vector3 screenPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
Vector3 screenPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
transform.position = new Vector3(screenPoint.x, screenPoint.y, transform.position.z);
|
transform.position = new Vector3(Mathf.Clamp(screenPoint.x, min.x, max.x), Mathf.Clamp(screenPoint.y, min.y, max.y), transform.position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
Vector3 screenPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
Vector3 screenPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
rigidbody2D.MovePosition(new Vector3(screenPoint.x, screenPoint.y, transform.position.z));
|
rigidbody2D.MovePosition(new Vector3(Mathf.Clamp(screenPoint.x, min.x, max.x), Mathf.Clamp(screenPoint.y, min.y, max.y), transform.position.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue