YRotation = Mathf.Clamp(yRotation, -25f, 20f) PlayerBody.Rotate(Vector3.left * mouseY) ![]() using UnityEngine Ĭursor.lockState = CursorLockMode.Locked įloat mouseX = Input.GetAxis("Mouse X") * speed * ltaTime įloat mouseY = Input.GetAxis("Mouse Y") * speed * ltaTime Your final code would look something like this assuming you are going to change the second value the same way as the yRotation variable. Either way, to add another axis just add another variable and add it to the last line in your code. Looking at the documentation ( ), the first value is the x rotation so you are actually using the yRotation value to change the x rotation. This way we stay in the left or right blend trees as much as possible to minimize transitions and we can always transition directly to the state we want.Just add another variable ( float xRotation) and in the transform.localRotation = Quaternion.Euler(yRotation, 0f, 0f) change the second value to xRotation. The left and right trees can transition directly to each other based on the side variable, but cannot transition to the top tip but they can be reached from the top tip. Left point: blend tree of run forward and strafe leftīlend trees on the side points blend to a 100% side strafe when forwards=0 and 100% forward run when forward=1 I form a diamond with a cross in the middle. I have a blend tree that works good for movement anywhere between East North and West (havent gotten to southern directions yet). I'd love it if someone would provide a controller and the code for input using mecanim that does basic WASD motion as seen in the Bootcamp demo. But no strafing.Īnd that's because if you try to combine strafing on the horizontal axis with forwards and backwards on the vertical axis in the same blend tree, the blend system has to pass through the strafe horizontal states in order to get to the vertical states and you see glitches in the animation. The forwards blend has blending for running right, straight and left forwards. They use one state for backwards and a seperate state/blend tree for forwards. I also find it a little odd that in the Mecanim demos and tutorials they do provide, the character movement is some weird variation that you would never use in a game. I could be wrong but I have not seen any demo or tutorial using Mecanim that replicates what is provided in the Bootcamp demo (proper WASD motion). ![]() ![]() Until that happens, I'm not sure you can even achieve the Bootcamp demo character WASD motion. According to the last Ninja Camp, they showed a video of them working on Blend Trees that allow 2 variables or 2 axis for blending. My best guess is Mecanim can't actually do correct WASD motion in it's current version because it can only blend one axis (either Horizontal or Vertical) but not both in a blend tree. Well let me know if you find a solution but I think the problem is the scripting not the blending. Instead they give examples of a guy running with a weird tight turn that no one would ever use in a real game. It's so strange because that's the most basic control setup but the Mecanim demos and tutorial examples all somehow avoid a basic FPS or third person controller setup with no strafing. I've been searching the asset store and as many mecanim examples as I can find but I have yet to find a Animator Controller and script that uses strafe left/right blended together with Walk forward and backward. It appears that for a humanoid character, we need a different equation but I don't know what it is yet. It only works if you are switching axis from vertical to horizontal but not horizontal to horizontal or vert to vert. ![]() Instead it makes an abrupt full switch from -90 to 90. I believe the problem is that the equation does not smoothly transition from -90 to 90, for example as you go left to right. However it works fine if you got up to right to down to left back to up in a circular sequence. It does not transition smoothly at all if you arrow up to down or right to left and visa versa. When you transition from left strafe to right strafe, there is a terrible glitch or blip in the animation. The following direction equation used in the minebot script is the source of the problem.I think:Īvatar.SetFloat("Direction", Mathf.Atan2(h,v) * 180.0f / 3.14159f) I believe I know what the problem is but I don t know how to fix it. I'm dealing with this exact issue as well right now.
0 Comments
Leave a Reply. |