Spacetime-Meta / spacetime-sdk

The spacetime-sdk is a turnkey virtual environment package for building in the Spacetime Metaverse
https://www.spacetimemeta.io/metaverse/spawn-planet
MIT License
11 stars 2 forks source link

Character face walking direction #49

Closed Liquid-Blocks closed 2 years ago

Liquid-Blocks commented 2 years ago

When the view is in 3rd person, the character does not always face the direction he his walking.

https://user-images.githubusercontent.com/46661277/167970550-2f9aba8d-26ea-4321-9c4e-019a4ebdf7ea.mp4

codeeMadness commented 2 years ago

Hi @Liquid-Blocks, I'm quite struggle with calculating location or rotation. Could you please to advise if we have any tool to locate the coordinator? It would be so helpful. Regards,

codeeMadness commented 2 years ago

btw, all directions I implemented so far is fine, except backward move. Sometimes it loads with different face directions.

https://user-images.githubusercontent.com/102911684/168129750-5602196e-ba42-4647-a5bd-c6c2f89ae38b.mp4

codeeMadness commented 2 years ago

Hi @Liquid-Blocks ,

I have resolved the issue below, it's ok now.

Just one more concerns, if our Player stops moving, should it keep its face direction?

Liquid-Blocks commented 2 years ago

Hi @codeeMadness, this is very good work for achieving the goal of setting the facing rotation!

I have experimented with it a bit and think it is a good suggestion to keep the facing direction when Player stops moving.

There is only one thing, the implementation introduces a new check of the users input.

As shown in the image below, the input catching logic is duplicated between the PlayerLocal.update and AvatarController.rotateFaceDirection.

image

Ideally, to optimize the update loop, we would:

  1. Catch the user input only in the PlayerLocal.
  2. Execute the logic to find the new rotation inside PlayerLocal.update
  3. Adjust the capsules rotation using the attribute THREE.Object3D.quaternion from its parent.
  4. Pass the quaternion to the AvatarController as an argument of AvatarController.update
  5. Then the AvatarController would only copy the capsules facing rotations using AvatarController.applyQuaternion, inherited from its THREE.Object3D parent.

Now we have 2 options,

  1. Do the changes now in this issue
  2. Merge this branch with develop and open a new issue for the optimization

I tend to prefer the second option since it keeps a better track of what is going on, so i will merge these changes into develop and open a new issue for the rest

Liquid-Blocks commented 2 years ago

This issues will be continued in an other optimization related issue

edit: Follow up in issue #59