Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Mupp on April 14, 2018, 07:26:09 PM

Title: Moving along a line using vector3
Post by: Mupp on April 14, 2018, 07:26:09 PM
I have an object that checks the slope under it by firing 2 raycasts every frame, one to the left of it and one to the right.

Now how can I create a "line" between those 2 vector3? I want to move the object along this line by pressing right, and to the opposite direction when pressing left. If possible by using set velocity.
Title: Re: Moving along a line using vector3
Post by: djaydino on April 15, 2018, 05:32:08 PM
Hi,
maybe you can use 'move toward' action?
Title: Re: Moving along a line using vector3
Post by: Mupp on April 15, 2018, 06:08:21 PM
No, these 2 points are on the object that's going to move.

Let me phrase differently.

I have 2 world points as vector3. I want the angle/direction from the line between these 2 points as a vector3.

I've tried vector3 operator angle, but that returns 0.
Title: Re: Moving along a line using vector3
Post by: Mupp on April 22, 2018, 09:37:41 AM
Bump time.

I still kinda need to know how to convert a velocity float, using a vector3 angle and get the result as a vector3.
Title: Re: Moving along a line using vector3
Post by: tcmeric on April 22, 2018, 01:18:32 PM
I thought I already replied to this. Strange.

Here are two actions to get the direction between two points. You can use this as your direction for movement.

Use these actions to get the direction and use the normalize option. This will give you the 'heading" for the movement direction.
Title: Re: Moving along a line using vector3
Post by: Mupp on April 22, 2018, 03:33:07 PM
Nice, didn't think there were custom actions for this. Thanks. :)

But one thing though, I still don't understand how to apply the velocity to the normalized vector.
Title: Re: Moving along a line using vector3
Post by: tcmeric on April 23, 2018, 12:34:09 AM
Try the action vector3 multiply.

Give it a value of 10 or more at first, just to see how it works.
Title: Re: Moving along a line using vector3
Post by: Mupp on April 23, 2018, 08:20:48 AM
Multiply? There's no way that's how you do it. If the direction is 0, 0, 0 then the magnitude would also be 0.
Title: Re: Moving along a line using vector3
Post by: tcmeric on April 23, 2018, 10:00:42 AM
The direction would only be 0,0,0 if they were on top of each other.
Title: Re: Moving along a line using vector3
Post by: Mupp on April 23, 2018, 10:43:54 AM
Right, got it. Thanks. :)