I've adapted this for a first person movement script. I'm going to try and work some lerp functions into this somehow. I wouldn’t have had a clue where to start if it wasn't for this vid. thank you
Hello! :D i have a problem, can you help me, please? my character doesnt keep hanging the edge :C im using a raycast jump this is my jump code do you need my entire code? private void PlayerJump() { if (Input.GetButtonDown("Jump") && isGrounded) { if(hanging) { _rb.useGravity = true; hanging = false; _rb.AddForce(Vector3.up * Jump, ForceMode.Impulse); StartCoroutine(EnableCantMove(0.25f)); } else { _rb.AddForce(Vector3.up * Jump, ForceMode.Impulse); } } }
@@RacTeamGames if you're having trouble with the basics like adding a variable I suggest you first take a step back and go through some of my unity basics videos ru-vid.com/group/PLoReGgpfex3xS-zXTujxo_flRkLBgxxd3
Hello I been having some issues with my fwdRayCast and tried using a debug to see why my player wasn't finding the ledge. It seems to only register the Down hit raycast are there any solutions to this problem? //Foward Cast if (downHit.collider != null) { Debug.Log("DOWN HIT"); lineFwdStart = new Vector3(transform.position.x + downHit.point.y - 0.1f, transform.position.z); lineFwdEnd = new Vector3(transform.position.x + downHit.point.y - 0.1f, transform.position.z) + transform.forward; Physics.Linecast(lineFwdStart, lineFwdEnd, out forwardHit, hangMask); Debug.DrawLine(lineFwdStart, lineFwdEnd, Color.red); if (forwardHit.collider != null) { Debug.Log("FWD HIT"); rb.useGravity = false; rb.velocity = Vector3.zero; isHanging = true; //Hang animation Vector3 hangingPos = new Vector3(forwardHit.point.x, downHit.point.y, forwardHit.point.z); Vector3 offset = transform.forward * -0.1f + transform.up * -1f; hangingPos += offset; transform.position = hangingPos; transform.forward = -forwardHit.normal; } }
i'm thinking it might be this line lineFwdEnd = new Vector3(transform.position.x + downHit.point.y - 0.1f, transform.position.z) + transform.forward; you're adding transform.forward to it, which is correct but now your line cast is only casting a really short distance in front of the character, just 1 single unit. you want to probably muliply that transform.forward by some number (i'd suggest making it a variable to test out what number works best)
@@thegamedevcave Thank you the player is starting to react! to the hanging but is off and sometimes will be hanging about the wall haha. I also saw i had an error in my code i had: lineFwdEnd = new Vector3(transform.position.x + downHit.point.y - 0.1f, transform.position.z) + transform.forward; istead of: lineFwdEnd = new Vector3(transform.position.x, downHit.point.y - 0.1f, transform.position.z) + transform.forward; 🤦♂😂