dotrix icon indicating copy to clipboard operation
dotrix copied to clipboard

Forward Vector

Open Xaniaro opened this issue 4 years ago • 5 comments

We need a function to calculate the forward vector. It is daily bread when you want to move some object in the direction its facing. Like this: https://docs.unity3d.com/ScriptReference/Transform-forward.html https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/Transformation/GetForwardVector/index.html

It will be handle to also implement up and right.

  • [ ] transform.forward()
  • [ ] transform.up()
  • [ ] transform.right()

Xaniaro avatar Apr 11 '21 20:04 Xaniaro

Perhaps I am misunderstanding this but isn't this just forward in local space but translated to world space? Can't this computed trivially with the object transform matrix and some units vectors?

QuantumEntangledAndy avatar Jan 17 '22 09:01 QuantumEntangledAndy

Yes, I think you are right. It may be trivial.

Xaniaro avatar Jan 19 '22 14:01 Xaniaro

The only complication I could see would be if we had a parenting system. In which case we would have to transverse up the tree to learn the combined world matrix.

Where would we want such a transform.forward() to reside? Part of the Transform component?

Should we implement it now or wait until we have Parent components?

If we add a parent component I would except we would need read access to World so that we could look up the transforms and parents components recursivly.

QuantumEntangledAndy avatar Jan 21 '22 00:01 QuantumEntangledAndy

I was thinking about parenting. I see it using a new Parent component that will contain EntityId of a parent. For Parent entity itself it must present as well. The worst thing that may happen is if we will have to iterate over these entities twice in parenting system.

voxelias avatar Jan 21 '22 14:01 voxelias

I was thinking of implementing my own Parent component but I couldn't seem to find a method in ecs that lets me grab the component if I know the Entity. The only way to grab comonents seemed to be with query which iterates everything did I miss something?

QuantumEntangledAndy avatar Jan 22 '22 04:01 QuantumEntangledAndy