Jump to content
Sign in to follow this  
Jimin Park

How do you get a position in front of the player?

Recommended Posts

Let's say a player is facing a certain direction.

I need vector position that is exactly 7 distance away from the player to a position it is facing.

How could this be obtained in Visual Scripting?

  • Upvote 1

Share this post


Link to post
Share on other sites

For those of you who are wondering how, I found an OK solution for this for the current version of Ylands.

What I ended up doing was

  • I created Reference Point game logic and set it animated.
  • Make this Reference Point game logic follow the player with offset 0, 0, 7 (Z value here can be any distance away from the character you want
  • Whenever you need to find a point that is infront of the character, you can use the position of that Reference Point that is following the character constantly at the front of the character.

As you can see this is a bit of a hack but it works. If anybody knows a better way to do this please let me know.

Edited by Jimin Park

Share this post


Link to post
Share on other sites

There is a better way than using the reference point. It's what I use to make some magic weapons and things. 

You'll need to be able to reference the player in the visual script, so you'll need to be able to get your characters position and rotation.

 

all you need to do is copy the Position tab in this picture.      1279298725_Screenshot(8).thumb.png.c98ed9024ffe1e84a15479c277a66fa9.png

The picture is basically an example of a particle effect playing in front of the caster at a set distance and height.

it is basically getting the position of your player and adding a set value for distance and height in the direction you're facing. 

I the VECTOR tab, X and Z are what is getting your rotation. The Y value is how high off the ground you want your point to be. The last number in the Position tab is how far you want your point to be in front or (if negative) behind your character.

 

Extra Explanation:

in the VECTOR tab X and Z are getting the Sin and Cos of the Y value of your character's rotation. The Y value of your character's rotation is the degree at which your character is rotated. When you plug the Sin in the X spot and the Cos in the Z spot, they cancel out to give you the direction you're facing. There is another post in these forums that explains that better, something about throwing a ball or something. 

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Hi, another option is to use "Transfrom position" script tile.

transformposition.PNG

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Houp said:

Hi, another option is to use "Transfrom position" script tile.

transformposition.PNG

@Jimin Park
Keep in mind something. (This is particularly useful to animations)


Set/Get Position will always be relative to the world coordinates.

Transform Position will always be relative to the local object/entity.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×