Closed
Conversation
Closed
jakezira
reviewed
Sep 16, 2022
character-controller.js
Outdated
| this.addAction(grabAction); | ||
|
|
||
| physicsScene.disableAppPhysics(app) | ||
| if(this instanceof LocalPlayer) { |
Contributor
There was a problem hiding this comment.
Need spacing.
Why is this check needed?
character-controller.js
Outdated
| position = h.position; | ||
| quaternion = h.quaternion; | ||
| } else { | ||
| position = this.position; |
Contributor
There was a problem hiding this comment.
What was wrong with previous implementation?
Contributor
Author
There was a problem hiding this comment.
Before, the grabbed object was moved around camera.position as pivot point. When 3rd person mode was entered, the object would move backwards with the camera. To prevent that I set the pivot point at localPlayer.position.
game.js
Outdated
| // .add(localVector2.set(0, 0.01, 0)); | ||
| const collision = | ||
| collisionEnabled && physicsScene.raycast(localVector, localQuaternion); | ||
| localQuaternion2.setFromAxisAngle(localVector2.set(1, 0, 0), -Math.PI * 0.5); |
Contributor
There was a problem hiding this comment.
Is this correct indentation?
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the following issues when editing scenes:
- Grabbed object transform out of sync
object.updateMatrixWorldwas called before the transform, which caused jitters.- Collisions
Querying only forward collision resulted in the
objectgoing into the ground when the distance from localPlayer to collision point was bigger than the grab offset. I addeddownCollisionto prevent that. By raycasting fromobjectperpendicularly down returns the collisionpointwith the ground.object.position.ywill then be clamped to be >=point.y.- Pivot point
Before, the grabbed object was moved around
camera.positionas pivot point. When 3rd person mode was entered, the object would move backwards with the camera. To prevent that I set the pivot point atlocalPlayer.position.Videos
Before:
https://user-images.githubusercontent.com/49231818/190644219-ac9d3d79-9afb-4f5a-8b63-4cdb7ca29c0a.mp4
After:
https://user-images.githubusercontent.com/49231818/190644313-43e0136b-d9ec-4176-ab56-8b49381b403e.mp4