Closed IJCoding closed 3 years ago
When rotating it causes a warping
the player only moves with it when this code is commented out
Otherwise it just stays in place
@DoctorMikeReddy I'm not sure how to fix this. Any help would be much appreciated :)!
@SharktallicA if you could help that would also be great :D
You happy to take this one, Khalid?
You happy to take this one, Khalid?
Yeah, no problem. I'll take a look at this on Monday.
My apologies, was busier than I anticipating yesterday. I can take a look this afternoon - @30005209, is there any specific branch I should be checking out?
@30005209 I believe I've got a fix! TLDR - in platformMovement, you need to work out the direction the platform is going and use that along with the speed variable to move the player via the CharacterController during the Update loop for the entire time the player is on the platform.
Steps:
player
variable for this) whilst it is on the platform. OnTriggerStay
and OnTriggerExit
will be sufficient.lastPos
in the class's scope, which will store the platform's position from during the last Update loop. Assign it the value of transform.position
at the very end of Update.Update
, and give it the value of (transform.position - lastPos).normalized
. This will be the direction the platform is moving in. I know the heading
variable is similar, but trying to use that caused the player to continue moving even when the platform stopped moving.Move
method and pass in the value of (dir * speed) * Time.deltaTime
; This, of course, will move the player as intended.Player capture and release code:
The new movement code in Update:
In case you're wondering/curious why changing the parent caused the deformation - when you set the player's parent as the landing platform through code, the player will be affected the parent's scale values. So if the parent isn't a scale of 1,1,1, it will deform. You could technically work around this issue using a 'middleman' GameObject, but that still wouldn't solve the movement issue. But for future reference for solving such parent-child deformations, you create an empty GameObject in the root/highest level of the hierarchy with a scale of 1,1,1, then make that the child of an object with non 1,1,1 scaling, then place the player as a child of the middleman. When the middleman is assigned to as the child through Unity designer, it recalculates the scale of it automatically to maintain its shape, thus it becomes a stable point of reference for your player.
Anyway, I digress. Hopefully that helps, and lemme know if you need anything else!
Just remember🧕, where possible, always avoid scaling anything other than in engine primitive shapes away from 1:1:1
Thank you so much :D @SharktallicA
And oh @DoctorMikeReddy I think some of us (myself included) have scaled in level so we'll go back and scale in the proper way :D
Scaling imported items can really mess with the default physics as well :-(
I'll go and fix the scaling for the main character :)
Main character's scale has been changed to 1,1,1 using the middleman way khalid recommended above
I changed the scale of the player using a "middleman gameobject" khalid recommended, and in game everything is sized as expected, but in the scene the player appears huge. Any ideas why this happens? @SharktallicA
Just assigned you @lordexishigh as you have already started working on it :)
If you want a hand please - reassign me :D
Ive been trying to get this to work, but ive been having a hard time figuring out a way for the platform to detect the player colliding with it. I tried rigidbody and played around with the code but nothing worked (see video on how it worked with rigidbody). The code works if the player variable is assigned manually, but i cant get it to work with the collision. Any ideas?
When i manually attached the player to the platform:
When attached a rigidbody to the platform
I changed the scale of the player using a "middleman gameobject" khalid recommended, and in game everything is sized as expected, but in the scene the player appears huge. Any ideas why this happens? @SharktallicA
Sorry, I never received an email notification for this tag. If it's still presently an issue, I can take a look soon and get back to you. Will do for the latest one issue from 18 hours ago, too.
Yes please, both are still unsolved. Everything is on the bugfixess branch. @SharktallicA
Hey @SharktallicA, have you had the time to have a look at this?
For the first issue, it seems Armature
's scale is always been set to 43.76699 from 437.6699 when the game is played. I couldn't find out exactly what was causing it though - best guess is that some part of the code is manually setting it or perhaps one of your animations modifies scale? I can take a deeper one once I've finished with the other issue.
As for the second issue, I'm still trying solutions. I'll get back to you shortly.
Sorry I don't have any better news, but I've still got some ideas.
i found a fix for the scale bug and had another look on the other issue but couldnt find a solution for it sadly. @SharktallicA
@SharktallicA Any progress on this?
@SharktallicA Any progress on this?
Unfortunately, I've still had no luck. It's puzzling.
I found a solution and but i only made it for only one single platform
Found a solution using a second collision detection which is trigger along with the mesh collision and tweaking the code a bit. This is done so closing issue. Thank you @SharktallicA
Should the player wish to stand on the platform it doesn't take them with them.
I've tried out a lot of tutorials online that shows I need to reset the parent of the player however, doing so causes some odd bugs...