Stride Forums Archive

[Solved] How can I get object in center of screen?

6 posts, 1271 views, 2016-09-16 to 2016-09-19

GayPornStudio (Vasilii Filippov) 2016-09-16 #1

Entity has camera subobject and I want to get an entity in front of it.
I tried this but it always returns false.

    var direction = Vector3.UnitZ;
    Entity.Transform.Rotation.Rotate(ref direction);
    var hitTest = _rigidbody.Simulation.Raycast(Entity.Transform.Position, Entity.Transform.Position + direction * 10);
    Debug.WriteLine($"Hit: {hitTest.Succeeded}, {direction}");
sinkingsugar 2016-09-16 #2

Did you properly add physics colliders in all those entities ?

GayPornStudio (Vasilii Filippov) 2016-09-16 #3 in reply to #2

Added rigidbody with box collider.

EternalTamago 2016-09-17 #4

Hello.
I think the camera is facing in the opposite direction of the owner entity.

var direction = -Vector3.UnitZ;

GayPornStudio (Vasilii Filippov) 2016-09-17 #5 in reply to #4

I tested all directions before though tried that for clarity and it didn’t help. OK, here’s actual project.
But thanks for tip about camera, it was turned to negative Z indeed :slight_smile:

GayPornStudio (Vasilii Filippov) 2016-09-19 #6 in reply to #5

Ok, it just solved itself somehow