BroDeee
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; } } }
1 replies
WallClimb 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; } } }
1 replies
wall climbing script
I just started learning coding, and I'm trying to make a wall-climbing script. But I don't know how to make it not move vertically under the "else” section. Here is the piece of code.
using System.Collections; using UnityEngine; private void OnCollisionEnter2D(Collider2D other) { If (other.CompareTag(“Wall”)) { Vector3 playerInput. = new Vector3(0, Input.GetAxisRaw(“Vertical”), 0); } else { Vector3 playerInput. = new Vector3(0, Input.GetAxisRaw(“Vertical”), 0) } }
using System.Collections; using UnityEngine; private void OnCollisionEnter2D(Collider2D other) { If (other.CompareTag(“Wall”)) { Vector3 playerInput. = new Vector3(0, Input.GetAxisRaw(“Vertical”), 0); } else { Vector3 playerInput. = new Vector3(0, Input.GetAxisRaw(“Vertical”), 0) } }
8 replies