playMaker

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

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Moving along a line using vector3
« on: April 14, 2018, 04: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: 5546
    • View Profile
    • jinxtergames
Re: Moving along a line using vector3
« Reply #1 on: April 15, 2018, 02:32:08 PM »
Hi,
maybe you can use 'move toward' action?

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Moving along a line using vector3
« Reply #2 on: April 15, 2018, 03: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

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Moving along a line using vector3
« Reply #3 on: April 22, 2018, 06: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
    • View Profile
Re: Moving along a line using vector3
« Reply #4 on: April 22, 2018, 10:18:32 AM »
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

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Moving along a line using vector3
« Reply #5 on: April 22, 2018, 12: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
    • View Profile
Re: Moving along a line using vector3
« Reply #6 on: April 22, 2018, 09:34:09 PM »
Try the action vector3 multiply.

Give it a value of 10 or more at first, just to see how it works.

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Moving along a line using vector3
« Reply #7 on: April 23, 2018, 05: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
    • View Profile
Re: Moving along a line using vector3
« Reply #8 on: April 23, 2018, 07:00:42 AM »
The direction would only be 0,0,0 if they were on top of each other.

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Moving along a line using vector3
« Reply #9 on: April 23, 2018, 07:43:54 AM »
Right, got it. Thanks. :)