playMaker

Author Topic: Moving along a line using vector3  (Read 2215 times)

Mupp

  • Full Member
  • ***
  • Posts: 167
Moving along a line using vector3
« 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Moving along a line using vector3
« Reply #1 on: April 15, 2018, 05:32:08 PM »
Hi,
maybe you can use 'move toward' action?

Mupp

  • Full Member
  • ***
  • Posts: 167
Re: Moving along a line using vector3
« Reply #2 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.

Mupp

  • Full Member
  • ***
  • Posts: 167
Re: Moving along a line using vector3
« Reply #3 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.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Moving along a line using vector3
« Reply #4 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.

Mupp

  • Full Member
  • ***
  • Posts: 167
Re: Moving along a line using vector3
« Reply #5 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.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Moving along a line using vector3
« Reply #6 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.

Mupp

  • Full Member
  • ***
  • Posts: 167
Re: Moving along a line using vector3
« Reply #7 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.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Moving along a line using vector3
« Reply #8 on: April 23, 2018, 10:00:42 AM »
The direction would only be 0,0,0 if they were on top of each other.

Mupp

  • Full Member
  • ***
  • Posts: 167
Re: Moving along a line using vector3
« Reply #9 on: April 23, 2018, 10:43:54 AM »
Right, got it. Thanks. :)