Added camera tracking and movement

This commit is contained in:
2021-07-19 11:45:08 +02:00
parent a9d82d1783
commit cfc51abde4
14 changed files with 366 additions and 56 deletions

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraTracking : MonoBehaviour
{
public Transform player;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Vector3 playpos = player.transform.position;
playpos.z = playpos.z - 10;
transform.position = playpos;
}
}

View File

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

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControls : MonoBehaviour
{
public Rigidbody2D rb;
public CircleCollider2D circ;
public LayerMask LVLMask;
public float walking_speed;
public float jump_power;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float speed = Input.GetAxisRaw("Horizontal") * Time.deltaTime;
Vector2 movement = new Vector2(0, 0);
movement.x = walking_speed * speed;
if (Input.GetButtonDown("Jump") || Input.GetAxisRaw("Vertical") > 0)
{
if (circ.IsTouchingLayers(LVLMask)){
movement.x = movement.x / 10;
movement.y = jump_power;
}
}
rb.AddRelativeForce(movement);
}
}

View File

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