-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstretchSkew.cs
36 lines (29 loc) · 1.01 KB
/
stretchSkew.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using UnityEngine;
using System.Collections;
public class stretchSkew : MonoBehaviour {
public Rigidbody2D RGB;
public Transform TRN;
private float RotateOffset = 0;
private float ROS;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
transform.position = TRN.position;
TRN.localPosition = Vector3.zero;
float angle = Mathf.Atan2(RGB.velocity.y, RGB.velocity.x) * Mathf.Rad2Deg;
Vector3 Rot = transform.rotation.eulerAngles;
Rot.z = angle;
transform.rotation = Quaternion.Euler(Rot);
ROS = Mathf.DeltaAngle(RotateOffset, -angle);
TRN.Rotate(0, 0, ROS,Space.Self);
RotateOffset += ROS;
if (RGB.velocity.magnitude < 10f)
transform.localScale = new Vector3(1, 1f - 0.5f * (RGB.velocity.magnitude) / 10, 1);
else
transform.localScale = new Vector3(1, 0.5f, 1);
}
}