wall climb script
My script i made isn't working, i think its because the player has rigidbody so it cant move vertically. does someone know how to fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WallClimb : MonoBehaviour
{
public float speed;
private void Start()
{
}
private void Update()
{
} private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Wall")) { Debug.Log("Touching Wall!"); Vector3 playerInput = new Vector3(0, Input.GetAxisRaw("Vertical"), 0); transform.position = transform.position + playerInput.normalized * speed * Time.deltaTime; } else { Vector3 playerInput = new Vector3(0, 0, 0); transform.position = transform.position + playerInput.normalized * speed * Time.deltaTime; } } }
} private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Wall")) { Debug.Log("Touching Wall!"); Vector3 playerInput = new Vector3(0, Input.GetAxisRaw("Vertical"), 0); transform.position = transform.position + playerInput.normalized * speed * Time.deltaTime; } else { Vector3 playerInput = new Vector3(0, 0, 0); transform.position = transform.position + playerInput.normalized * speed * Time.deltaTime; } } }
0 Replies