adding in some needed packages
This commit is contained in:
parent
9e739f5dc8
commit
aba5310742
1012 changed files with 494191 additions and 1 deletions
36
Assets/Bremsengine/2D Ragdoll Arms/RagdollArm2D.cs
Normal file
36
Assets/Bremsengine/2D Ragdoll Arms/RagdollArm2D.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Core.Extensions;
|
||||
|
||||
namespace Bremsengine
|
||||
{
|
||||
public class RagdollArm2D : MonoBehaviour
|
||||
{
|
||||
float rotation = 0f; // this is nan
|
||||
float velocityY = 0f;
|
||||
[SerializeField] float lerpSpeed = 10f;
|
||||
[SerializeField] float idleRotation = -45f;
|
||||
[SerializeField] float fallRotation = 45f;
|
||||
float lerp = 0f; //this is also nan
|
||||
Vector2 lastPosition = Vector2.zero;
|
||||
[SerializeField] bool flip;
|
||||
private void Update()
|
||||
{
|
||||
velocityY = (transform.position.y - lastPosition.y) * (1f / Time.deltaTime);
|
||||
float fallDot = (15f - (15f - velocityY)) / 15f;
|
||||
|
||||
lerp = (float.IsNaN(lerp) ? 0f : lerp) + (-fallDot * Time.deltaTime * lerpSpeed);
|
||||
if (lerp > 0f && velocityY > -2f)
|
||||
{
|
||||
lerp -= Time.deltaTime * lerpSpeed;
|
||||
}
|
||||
lerp = lerp.Clamp(0f, 1f);
|
||||
lastPosition = transform.position;
|
||||
|
||||
rotation = idleRotation.Lerp(fallRotation, lerp);
|
||||
Vector2 look = (Vector2)transform.position + (!flip ? Vector2.right.Rotate2D(rotation) : Vector2.left.Rotate2D(rotation));
|
||||
transform.Lookat2D(look);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Bremsengine/2D Ragdoll Arms/RagdollArm2D.cs.meta
Normal file
11
Assets/Bremsengine/2D Ragdoll Arms/RagdollArm2D.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 51d3babb9e31f784787cccc2e0abcb45
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue