C
C#9mo ago
BroDeee

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) } }
6 Replies
SparkyCracked
SparkyCracked9mo ago
To prevent the player from moving vertically when not in contact with a wall, you can simply set the vertical input to zero in the "else" section of your code.
BroDeee
BroDeeeOP9mo ago
Ohh Thank you
SparkyCracked
SparkyCracked9mo ago
No stress. If you need the code snippet it will look like this: Vector3 playerInput. = new Vector3(0, 0, 0);
BroDeee
BroDeeeOP9mo ago
Thank you
SparkyCracked
SparkyCracked9mo ago
$close
MODiX
MODiX9mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server