Added moving and teleporting platforms in ObstanceWIP. Falling Platform is a WIP
Falling Platforms don't work yet. Still haven't figured out how to make it fall
This commit is contained in:
@@ -19,9 +19,10 @@ GameObject:
|
|||||||
- component: {fileID: 2344147968324054325}
|
- component: {fileID: 2344147968324054325}
|
||||||
- component: {fileID: 8121950008105218343}
|
- component: {fileID: 8121950008105218343}
|
||||||
- component: {fileID: 2813634395235005482}
|
- component: {fileID: 2813634395235005482}
|
||||||
|
- component: {fileID: 6880649289615065196}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Bones
|
m_Name: Bones
|
||||||
m_TagString: Untagged
|
m_TagString: Player
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@@ -275,6 +276,20 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
blocking: 0
|
blocking: 0
|
||||||
|
--- !u!114 &6880649289615065196
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1375850422501237868}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 182a9e619d36aeb4592fb532d3c9db55, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
teleportPoint: {x: -5, y: -10}
|
||||||
|
teleportTag: Teleporter
|
||||||
--- !u!1 &1648017802882051395
|
--- !u!1 &1648017802882051395
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -94,9 +94,13 @@ GameObject:
|
|||||||
- component: {fileID: 2791557175355662981}
|
- component: {fileID: 2791557175355662981}
|
||||||
- component: {fileID: 3406519100105273690}
|
- component: {fileID: 3406519100105273690}
|
||||||
- component: {fileID: 251648003544978305}
|
- component: {fileID: 251648003544978305}
|
||||||
|
- component: {fileID: 4135832890425447844}
|
||||||
|
- component: {fileID: 7967725481535243710}
|
||||||
|
- component: {fileID: 6370585510696338442}
|
||||||
|
- component: {fileID: -5768905494704828194}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Player
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@@ -214,13 +218,15 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 9b920f65db6650d4aa4858ad8a795d19, type: 3}
|
m_Script: {fileID: 11500000, guid: 9b920f65db6650d4aa4858ad8a795d19, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
player:
|
|
||||||
ground:
|
ground:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 64
|
m_Bits: 64
|
||||||
|
playerText: {fileID: 0}
|
||||||
walkSpeed: 5
|
walkSpeed: 5
|
||||||
walkSpeedFactor: 30
|
walkSpeedFactor: 30
|
||||||
maxSpeed: 5
|
maxSpeed: 5
|
||||||
|
maxSpeedOverride: 0
|
||||||
|
slowdownMultiplier: 10
|
||||||
virtualAxisX: 0
|
virtualAxisX: 0
|
||||||
virtualButtonJump: 0
|
virtualButtonJump: 0
|
||||||
virtualButtonJumpLastFrame: 0
|
virtualButtonJumpLastFrame: 0
|
||||||
@@ -245,6 +251,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
spawnPoint: {x: 0, y: 0}
|
spawnPoint: {x: 0, y: 0}
|
||||||
|
spawnPointIsInitialPosition: 0
|
||||||
respawnTag: Platformer Hazard
|
respawnTag: Platformer Hazard
|
||||||
--- !u!61 &2791557175355662981
|
--- !u!61 &2791557175355662981
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
@@ -338,3 +345,69 @@ PlatformEffector2D:
|
|||||||
m_UseSideFriction: 0
|
m_UseSideFriction: 0
|
||||||
m_UseSideBounce: 0
|
m_UseSideBounce: 0
|
||||||
m_SideArc: 1
|
m_SideArc: 1
|
||||||
|
--- !u!95 &4135832890425447844
|
||||||
|
Animator:
|
||||||
|
serializedVersion: 7
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6546762253351562952}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Avatar: {fileID: 0}
|
||||||
|
m_Controller: {fileID: 0}
|
||||||
|
m_CullingMode: 0
|
||||||
|
m_UpdateMode: 0
|
||||||
|
m_ApplyRootMotion: 0
|
||||||
|
m_LinearVelocityBlending: 0
|
||||||
|
m_StabilizeFeet: 0
|
||||||
|
m_AnimatePhysics: 0
|
||||||
|
m_WarningMessage:
|
||||||
|
m_HasTransformHierarchy: 1
|
||||||
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
|
m_KeepAnimatorStateOnDisable: 0
|
||||||
|
m_WriteDefaultValuesOnDisable: 0
|
||||||
|
--- !u!114 &7967725481535243710
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6546762253351562952}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 6e9d01bde449c4d0fa146e06804d6a03, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
state: 0
|
||||||
|
backwards: 0
|
||||||
|
block: 0
|
||||||
|
clip: {fileID: 0}
|
||||||
|
--- !u!114 &6370585510696338442
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6546762253351562952}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9ae332d743f1a42ce8ee7a958853bcc1, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
cancelable: 1
|
||||||
|
hurtbox: {fileID: 0}
|
||||||
|
--- !u!114 &-5768905494704828194
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6546762253351562952}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 182a9e619d36aeb4592fb532d3c9db55, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
teleportPoint: {x: 0, y: 0}
|
||||||
|
teleportTag: Teleporter
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
31
Assets/Scripts/FallPlatform.cs
Normal file
31
Assets/Scripts/FallPlatform.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class FallPlatform : MonoBehaviour
|
||||||
|
{
|
||||||
|
public float fallDelay = 2f;
|
||||||
|
public float destroyDelay = 2f;
|
||||||
|
|
||||||
|
bool falling;
|
||||||
|
Rigidbody2D rb;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
rb = GetComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
|
private void OnCollisionEnter2D(Collider2D collision)
|
||||||
|
{
|
||||||
|
if (!falling && collision.gameObject.CompareTag("Player"))
|
||||||
|
{
|
||||||
|
StartCoroutine(FallAfterDelay());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator FallAfterDelay()
|
||||||
|
{
|
||||||
|
falling = true;
|
||||||
|
yield return new WaitForSeconds(fallDelay);
|
||||||
|
rb.bodyType = RigidbodyType2D.Dynamic;
|
||||||
|
Destroy(gameObject, destroyDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/FallPlatform.cs.meta
Normal file
2
Assets/Scripts/FallPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6d315bad368a8a247a5df8ac6b2f3ec1
|
||||||
30
Assets/Scripts/MovingPlatform.cs
Normal file
30
Assets/Scripts/MovingPlatform.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MovingPlatform : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Transform platform;
|
||||||
|
public int startPoint;
|
||||||
|
public Transform[] points;
|
||||||
|
public float speed;
|
||||||
|
|
||||||
|
private int i;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
transform.position = points[startPoint].position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (Vector2.Distance(transform.position, points[i].position) < 0.02f)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if (i == points.Length)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/MovingPlatform.cs.meta
Normal file
2
Assets/Scripts/MovingPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 15a2da7226a2f054b9f96b2769e449e2
|
||||||
28
Assets/Scripts/TeleportPlatform.cs
Normal file
28
Assets/Scripts/TeleportPlatform.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TeleportPlatform : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Vector2 teleportPoint;
|
||||||
|
//public bool teleportPosition = false;
|
||||||
|
public string teleportTag;
|
||||||
|
|
||||||
|
//private void Start()
|
||||||
|
//{
|
||||||
|
//if (teleportPosition)
|
||||||
|
//{
|
||||||
|
//teleportPoint = transform.position;
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void OnTriggerEnter2D(Collider2D collision)
|
||||||
|
{
|
||||||
|
if (collision.CompareTag(teleportTag))
|
||||||
|
{
|
||||||
|
transform.position = teleportPoint;
|
||||||
|
if (TryGetComponent<Rigidbody2D>(out var rb))
|
||||||
|
{
|
||||||
|
rb.linearVelocity = Vector2.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/TeleportPlatform.cs.meta
Normal file
2
Assets/Scripts/TeleportPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 182a9e619d36aeb4592fb532d3c9db55
|
||||||
@@ -8,6 +8,8 @@ TagManager:
|
|||||||
- Pong Paddle
|
- Pong Paddle
|
||||||
- Platformer Hazard
|
- Platformer Hazard
|
||||||
- Punch Hurtbox
|
- Punch Hurtbox
|
||||||
|
- Teleporter
|
||||||
|
- FallPlatform
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|||||||
Reference in New Issue
Block a user