CameraControl

dev-ali
Ali Sharoz 1 month ago
parent 8b1cde9c84
commit c594388ec7

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraManager : MonoBehaviour
{
public Transform MainCam;
public Transform StartingCamera;
Vector3 MainCamEulerAngles;
public Transform target; // Reference to the character
public float speed;
private void Start()
{
MainCamEulerAngles = MainCam.eulerAngles;
Invoke(nameof(StartingGameObjDisabler), 2.5f);
}
void StartingGameObjDisabler()
{
StartingCamera.gameObject.SetActive(false);
}
private void Update()
{
if (speed < 1)
speed += Time.deltaTime/10;
StartingCamera.position = Vector3.Lerp(StartingCamera.position, MainCam.position, speed);
StartingCamera.LookAt(target);
//StartingCamera.eulerAngles=Vector3.Lerp(StartingCamera.eulerAngles, MainCamEulerAngles, Time.deltaTime);
}
}

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

@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Costume-Mysto.001
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 10708, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
@ -59,6 +59,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Ramp:
m_Texture: {fileID: 2800000, guid: abc83c21d57d4a74cabe12065fa1a8b2, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
@ -72,6 +76,8 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _RampSmooth: 0.1
- _RampThreshold: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
@ -80,4 +86,6 @@ Material:
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _HColor: {r: 0.785, g: 0.785, b: 0.785, a: 1}
- _SColor: {r: 0.19499996, g: 0.19499996, b: 0.19499996, a: 1}
m_BuildTextureStacks: []

@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MainBody-Mysto.001
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 10708, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
@ -59,6 +59,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Ramp:
m_Texture: {fileID: 2800000, guid: abc83c21d57d4a74cabe12065fa1a8b2, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
@ -72,6 +76,8 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _RampSmooth: 0.1
- _RampThreshold: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
@ -80,4 +86,6 @@ Material:
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _HColor: {r: 0.785, g: 0.785, b: 0.785, a: 1}
- _SColor: {r: 0.19499996, g: 0.19499996, b: 0.19499996, a: 1}
m_BuildTextureStacks: []

@ -80,7 +80,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3345311276052987917}
m_Enabled: 0
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
@ -362,7 +362,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5440686397038675175}
m_Enabled: 0
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
@ -467,7 +467,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8673850858292973711}
m_Enabled: 0
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
@ -572,7 +572,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8963123750152084695}
m_Enabled: 0
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1

File diff suppressed because it is too large Load Diff

@ -14,6 +14,7 @@ public class RocketMovement : MonoBehaviour
Vector2 resPos = Vector2.zero;
public SimpleJoystick Joystick;
public bool rocketStarted;
private void Awake()
{
Instance = this;
@ -21,28 +22,36 @@ public class RocketMovement : MonoBehaviour
private void Start()
{
GameManager.DifficultyIncreased.AddListener(() => SpeedIncreaser());
rocketStarter();
//Invoke(nameof(rocketStarter), 5);
}
void rocketStarter()
{
rocketStarted = true;
}
void FixedUpdate()
{
if (Joystick.isActive)
{
resPos.x = oldPos.x + CnInputManager.GetAxis("Horizontal");
resPos.y = oldPos.y + CnInputManager.GetAxis("Vertical");
resPos.x = Mathf.Clamp(resPos.x, -1, 1);
resPos.y = Mathf.Clamp(resPos.y, -1, 1);
newPos.x = Mathf.Lerp(newPos.x, resPos.x, controllerSpeed);
newPos.y = Mathf.Lerp(newPos.y, resPos.y, controllerSpeed);
transform.position = new Vector3(newPos.x, transform.position.y, -newPos.y);
oldPos.x = newPos.x;
oldPos.y = newPos.y;
}
else
if (rocketStarted)
{
oldPos = resPos;
//oldPos = newPos;
if (Joystick.isActive)
{
resPos.x = oldPos.x + CnInputManager.GetAxis("Horizontal");
resPos.y = oldPos.y + CnInputManager.GetAxis("Vertical");
resPos.x = Mathf.Clamp(resPos.x, -1, 1);
resPos.y = Mathf.Clamp(resPos.y, -1, 1);
newPos.x = Mathf.Lerp(newPos.x, resPos.x, controllerSpeed);
newPos.y = Mathf.Lerp(newPos.y, resPos.y, controllerSpeed);
transform.position = new Vector3(newPos.x, transform.position.y, -newPos.y);
oldPos.x = newPos.x;
oldPos.y = newPos.y;
}
else
{
oldPos = resPos;
//oldPos = newPos;
}
transform.Translate(upSpeed * Time.deltaTime * Vector3.up);
}
transform.Translate(upSpeed * Time.deltaTime * Vector3.up);
}
void SpeedIncreaser()
{

Loading…
Cancel
Save