C
C#10mo 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
SparkyCracked10mo 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
BroDeeeOP10mo ago
Ohh Thank you
SparkyCracked
SparkyCracked10mo ago
No stress. If you need the code snippet it will look like this: Vector3 playerInput. = new Vector3(0, 0, 0);
BroDeee
BroDeeeOP10mo ago
Thank you
SparkyCracked
SparkyCracked10mo ago
$close
MODiX
MODiX10mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server