Browse Source

Merge branch 'main' of http://git.joshuareason.com/Jam/GGJ_2022 into main

main
Tau-er\Bobbster 2 years ago
parent
commit
141f1dce29
5 changed files with 64 additions and 5 deletions
  1. BIN
      Assets/Scenes/WalljumpTest.unity
  2. +4
    -2
      Assets/Scripts/CameraFollower.cs
  3. +46
    -0
      Assets/Scripts/PlatformMover.cs
  4. +11
    -0
      Assets/Scripts/PlatformMover.cs.meta
  5. BIN
      Assets/Variables/Runtime/freezePlayer.asset

BIN
Assets/Scenes/WalljumpTest.unity (Stored with Git LFS) View File

size 1740290

+ 4
- 2
Assets/Scripts/CameraFollower.cs View File

@ -9,6 +9,8 @@ public class CameraFollower : MonoBehaviour
[SerializeField] private float m_FollowStrength = 3f; [SerializeField] private float m_FollowStrength = 3f;
[SerializeField] private bool m_FollowX = true; [SerializeField] private bool m_FollowX = true;
[SerializeField] private bool m_FollowY = false; [SerializeField] private bool m_FollowY = false;
[SerializeField] private float m_OffsetX = 0f;
[SerializeField] private float m_OffsetY = 2.0f;
private Camera m_Camera; private Camera m_Camera;
@ -22,8 +24,8 @@ public class CameraFollower : MonoBehaviour
if(Mathf.Abs(Player.transform.position.x - m_Camera.transform.position.x) > m_FollowStrength) if(Mathf.Abs(Player.transform.position.x - m_Camera.transform.position.x) > m_FollowStrength)
{ {
m_Camera.transform.Translate( m_Camera.transform.Translate(
m_FollowX ? (m_FollowStrength + Player.transform.position.x - m_Camera.transform.position.x) * Time.deltaTime : 0,
m_FollowY ? (m_FollowStrength + Player.transform.position.y - m_Camera.transform.position.y) * Time.deltaTime : 0,
(m_FollowX ? (m_FollowStrength + Player.transform.position.x - m_Camera.transform.position.x - m_OffsetX) * Time.deltaTime : 0),
(m_FollowY ? (m_FollowStrength + Player.transform.position.y - m_Camera.transform.position.y - m_OffsetY) * Time.deltaTime : 0),
0); 0);
} }
} }

+ 46
- 0
Assets/Scripts/PlatformMover.cs View File

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformMover : MonoBehaviour
{
[SerializeField] private Transform m_StartPos;
[SerializeField] private Transform m_EndPos;
[SerializeField] private float m_Duration = 2f;
private Transform m_OldParent;
private void Update()
{
transform.position = Vector2.Lerp(m_StartPos.position, m_EndPos.position, (Mathf.Sin(Time.time * m_Duration) + 1.0f) / 2.0f);
}
private void OnCollisionEnter2D(Collision2D collision)
{
var playerController = collision.gameObject.GetComponent<CharacterController2D>();
if(playerController)
{
m_OldParent = playerController.transform.parent;
playerController.transform.parent = transform;
}
}
private void OnCollisionExit2D(Collision2D collision)
{
var playerController = collision.gameObject.GetComponent<CharacterController2D>();
if(playerController)
{
playerController.transform.parent = m_OldParent;
m_OldParent = null;
}
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Gizmos.color = Color.green;
Gizmos.DrawLine(m_StartPos.position, m_EndPos.position);
}
#endif
}

+ 11
- 0
Assets/Scripts/PlatformMover.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e37b7702510697041a7ae1a25956385b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Variables/Runtime/freezePlayer.asset (Stored with Git LFS) View File

size 466 size 466

Loading…
Cancel
Save