c# - First person controller getting stuck on walls -


i'm working on voxel based project similar minecraft , i'm running issue first person controller.

http://pastebin.com/xafcm8zc --> i'll post whole thing nothing important left out.

i have oncollisionstay method detects angle of wall i'm running (aka dont want able run 90 degree walls, or able spam jump climb mountains)

void oncollisionstay(collision collision){     foreach (contactpoint contactpoint in collision.contacts) {         groundnormal += contactpoint.normal;         if (contactpoint.normal.y > mathf.cos (slopelimit * mathf.deg2rad)) {             toosteep = false;         }     }     if (collision.contacts.length > 0) {         groundnormal /= collision.contacts.length;     }     grounded = true; } 

it works correctly, problem arises in fixedupdate method limit movement code via line:

    if (!toosteep || !grounded) { 

so can move if not steep, or i'm not grounded, i'm trying make can move wherever, not walk/jump walls.

i tried making "canjump" variable solves part of it. how can prevent user input affecting y velocity if user colliding wall steep?

called buddy of mine , stated obvious overlooked.

apparently unity's default colliders have level of friction on them. created physics material 0 coefficients both types of friction , working intended, need limit wall jumping isn't problem.

hopefully helps in future.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -