parallax effect v1.0.2

This commit is contained in:
KG0104 2021-10-23 17:49:56 +02:00
parent dd018431cf
commit 06404e1102
6 changed files with 44 additions and 25 deletions

View File

@ -1933,7 +1933,7 @@ HingeJoint2D:
m_BreakTorque: Infinity
m_AutoConfigureConnectedAnchor: 1
m_Anchor: {x: 0, y: 0}
m_ConnectedAnchor: {x: 1.5330272, y: 0.000013727693}
m_ConnectedAnchor: {x: 1.5330272, y: 0.000013543291}
m_UseMotor: 0
m_Motor:
m_MotorSpeed: 0
@ -15135,7 +15135,7 @@ HingeJoint2D:
m_BreakTorque: Infinity
m_AutoConfigureConnectedAnchor: 1
m_Anchor: {x: 0, y: 0}
m_ConnectedAnchor: {x: 1.6145648, y: 0.000011488793}
m_ConnectedAnchor: {x: 1.6145648, y: 0.000011680645}
m_UseMotor: 0
m_Motor:
m_MotorSpeed: 0

View File

@ -19,11 +19,11 @@ public class Parallaxing : MonoBehaviour
lastCameraPosition = cameraTransform.position;
Sprite sprite = GetComponent<SpriteRenderer>().sprite;
Texture2D texture = sprite.texture;
textureUnitSizeX = texture.width / sprite.pixelsPerUnit;
textureUnitSizeY = texture.height / sprite.pixelsPerUnit;
textureUnitSizeX = (texture.width / sprite.pixelsPerUnit) * transform.localScale.x;
textureUnitSizeY = (texture.height / sprite.pixelsPerUnit) * transform.localScale.y;
}
private void LateUpdate()
private void FixedUpdate()
{
Vector3 deltaMovement = cameraTransform.position - lastCameraPosition;
transform.position += new Vector3(deltaMovement.x * parallaxEffectMultiplier.x, deltaMovement.y * parallaxEffectMultiplier.y);
@ -43,8 +43,8 @@ public class Parallaxing : MonoBehaviour
if (Mathf.Abs(cameraTransform.position.y - transform.position.y) >= textureUnitSizeY)
{
float offsetPositionY = (cameraTransform.position.y - transform.position.y) % textureUnitSizeY;
transform.position = new Vector3(transform.position.y, cameraTransform.position.y + offsetPositionY);
transform.position = new Vector3(transform.position.x, cameraTransform.position.y + offsetPositionY);
}
}
}
}
}

View File

@ -4,5 +4,5 @@ using UnityEngine;
public class KeyHolder : MonoBehaviour
{
public Key followingKey;
[HideInInspector] public Key followingKey;
}

View File

@ -1,13 +1,13 @@
{
"dependencies": {
"com.unity.2d.animation": "5.0.5",
"com.unity.2d.animation": "5.0.8",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.cinemachine": "2.6.10",
"com.unity.collab-proxy": "1.3.9",
"com.unity.collab-proxy": "1.13.5",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.11",
"com.unity.render-pipelines.universal": "10.3.2",
"com.unity.render-pipelines.universal": "10.6.0",
"com.unity.test-framework": "1.1.29",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"com.unity.2d.animation": {
"version": "5.0.5",
"version": "5.0.8",
"depth": 0,
"source": "registry",
"dependencies": {
@ -43,10 +43,13 @@
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "1.3.9",
"version": "1.13.5",
"depth": 0,
"source": "registry",
"dependencies": {},
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.0",
"com.unity.services.core": "1.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
@ -81,8 +84,15 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.nuget.newtonsoft-json": {
"version": "2.0.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "10.3.2",
"version": "10.6.0",
"depth": 1,
"source": "registry",
"dependencies": {
@ -91,30 +101,39 @@
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.universal": {
"version": "10.3.2",
"version": "10.6.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.1.0",
"com.unity.render-pipelines.core": "10.3.2",
"com.unity.shadergraph": "10.3.2"
"com.unity.render-pipelines.core": "10.6.0",
"com.unity.shadergraph": "10.6.0"
},
"url": "https://packages.unity.com"
},
"com.unity.searcher": {
"version": "4.3.1",
"version": "4.3.2",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": {
"version": "10.3.2",
"com.unity.services.core": {
"version": "1.0.1",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.render-pipelines.core": "10.3.2",
"com.unity.searcher": "4.3.1"
"com.unity.modules.unitywebrequest": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": {
"version": "10.6.0",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.render-pipelines.core": "10.6.0",
"com.unity.searcher": "4.3.2"
},
"url": "https://packages.unity.com"
},

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2020.3.1f1
m_EditorVersionWithRevision: 2020.3.1f1 (77a89f25062f)
m_EditorVersion: 2020.3.21f1
m_EditorVersionWithRevision: 2020.3.21f1 (a38c86f6690f)