0 votes

i try to understand but i stuck on this chapter
How can i get Vector F or i have to create by myself like raycast

reference document

enter image description here

Please excuse my poor English.
Thank you.

in Engine by (30 points)

1 Answer

+1 vote
Best answer

In the doc, F can be any direction. It's simply where the enemy looks at. In this example, dot product allows you to tell how good B can see A, assuming there is no obstacle in the level. Good ol' vector math :p

If B is a Node2D (or any subtype of it), and is designed so that its sprite looks on the right, you can get F like this:

var F = B.get_global_transform().x

If B's sprite is designed to look down:

var F = B.get_global_transform().y

(Note that the 2D engine Y axis is pointing down, not up)

by (29,036 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.