PlaceholderGames / 2021-yr2-group-1

CS2S561 2020/1 Group 1
0 stars 0 forks source link

CharacterController not re-enabling , current needed fix for climbing (maybe Killbox) #124

Closed KieranG32 closed 3 years ago

KieranG32 commented 3 years ago

image

This is the most up to date code for the ladder, everything works fine up until re-enabling the player controller, if the controller could be re-enabled the player would no longer be able to move up the Y axis (climb) but forward again

image For the creation of ladder I added a 3D Cube Object and stretched the trigger box so the player can climb as they reach the ladder

I then added a C# script to the ladder so when the player enters the trigger (OnTriggerEnter) they would be able to move directly up (climb) until they was out of the trigger , this was achieved by disabling the CharacterController and then setting the W key to move the player up the Y axis

The CharacterController never re-enables though so the player can not move anywhere apart from Up the Y Axis , I tried different ways of trying to fix this, such as using OntriggerStay or a mix of move when the player enters and stop when they leave a trigger, or using Booleans referenced in Update (this checks every frame ) to try and achieve the same effect but none of this worked either

I tried to use a different 3D Cube with Trigger to re-enable the CharacterController but this also didnt work

I also tried to use while loops but this instantly crashed unity , to fix this you instead use a Coroutines , but again I couldn't get that to work , from testing different fixes and methods to achieve climbing I believe the reason it does not work is because the CharacterController never gets re-enabled

ReflectU commented 3 years ago

Fixed climbing by relocating and reworking it within the playerController