Merge branch 'master' of https://github.com/BRNSystems/GeoJam2021
This commit is contained in:
commit
008be6efea
@ -135,6 +135,7 @@ GameObject:
|
|||||||
- component: {fileID: 44549256}
|
- component: {fileID: 44549256}
|
||||||
- component: {fileID: 44549255}
|
- component: {fileID: 44549255}
|
||||||
- component: {fileID: 44549254}
|
- component: {fileID: 44549254}
|
||||||
|
- component: {fileID: 44549257}
|
||||||
m_Layer: 3
|
m_Layer: 3
|
||||||
m_Name: Circle
|
m_Name: Circle
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -244,6 +245,21 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!114 &44549257
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 44549252}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 20c0ecf95ac68c343bdf7b8295ff699c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
width: 0
|
||||||
|
height: -1.4
|
||||||
|
speed: 1.76
|
||||||
--- !u!1 &48681354
|
--- !u!1 &48681354
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -32243,6 +32259,7 @@ GameObject:
|
|||||||
- component: {fileID: 1657599957}
|
- component: {fileID: 1657599957}
|
||||||
- component: {fileID: 1657599956}
|
- component: {fileID: 1657599956}
|
||||||
- component: {fileID: 1657599955}
|
- component: {fileID: 1657599955}
|
||||||
|
- component: {fileID: 1657599958}
|
||||||
m_Layer: 3
|
m_Layer: 3
|
||||||
m_Name: Circle (1)
|
m_Name: Circle (1)
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -32352,6 +32369,21 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!114 &1657599958
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1657599953}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 20c0ecf95ac68c343bdf7b8295ff699c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
width: 0
|
||||||
|
height: -1.36
|
||||||
|
speed: 1.2
|
||||||
--- !u!1 &1748848846
|
--- !u!1 &1748848846
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
102
Assets/Scripts/MovingPlatform.cs
Normal file
102
Assets/Scripts/MovingPlatform.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MovingPlatform : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float width;
|
||||||
|
public float height;
|
||||||
|
[Range(0.1f, 8)] [SerializeField] private float speed = 1;
|
||||||
|
|
||||||
|
private bool movingLeft = false;
|
||||||
|
private bool movingUp = false;
|
||||||
|
|
||||||
|
Vector3 vector;
|
||||||
|
Vector3 object_position;
|
||||||
|
Vector3 furthest_position;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
vector = transform.position;
|
||||||
|
object_position = transform.position;
|
||||||
|
furthest_position = object_position;
|
||||||
|
furthest_position[0] += width;
|
||||||
|
furthest_position[1] += height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (width > 0) {
|
||||||
|
if (movingLeft) {
|
||||||
|
if (vector[0] > object_position[0]) {
|
||||||
|
vector[0] -= speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingLeft = !movingLeft;
|
||||||
|
vector[0] += speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vector[0] < furthest_position[0]) {
|
||||||
|
vector[0] += speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingLeft = !movingLeft;
|
||||||
|
vector[0] -= speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (width < 0) {
|
||||||
|
if (movingLeft) {
|
||||||
|
if (vector[0] > furthest_position[0]) {
|
||||||
|
vector[0] -= speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingLeft = !movingLeft;
|
||||||
|
vector[0] += speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vector[0] < object_position[0]) {
|
||||||
|
vector[0] += speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingLeft = !movingLeft;
|
||||||
|
vector[0] -= speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height > 0) {
|
||||||
|
if (movingUp) {
|
||||||
|
if (vector[1] < furthest_position[1]) {
|
||||||
|
vector[1] += speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingUp = !movingUp;
|
||||||
|
vector[1] -= speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vector[1] > object_position[1]) {
|
||||||
|
vector[1] -= speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingUp = !movingUp;
|
||||||
|
vector[1] += speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (height < 0) {
|
||||||
|
if (movingUp) {
|
||||||
|
if (vector[1] < object_position[1]) {
|
||||||
|
vector[1] += speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingUp = !movingUp;
|
||||||
|
vector[1] -= speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vector[1] > furthest_position[1]) {
|
||||||
|
vector[1] -= speed * Time.deltaTime;
|
||||||
|
} else {
|
||||||
|
movingUp = !movingUp;
|
||||||
|
vector[1] += speed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transform.position = vector;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/MovingPlatform.cs.meta
Normal file
11
Assets/Scripts/MovingPlatform.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 20c0ecf95ac68c343bdf7b8295ff699c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user