playMaker

Author Topic: Angled movement xy coords.  (Read 1549 times)

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Angled movement xy coords.
« on: November 29, 2019, 05:47:14 PM »
I move an object along XY coords. by offsetting its current position with a speed value. Speed=distance moved per frame to make it easy. There is one speed value for X axis and one for Y but they are both capped to the same value. This value starts at 0 and accelerates until it reaches max speed over a couple of frames. So the current speed value can be anything between negative max to positive max depending which direction it moves.

Now, where should the object be placed if both axis speed values are non 0? The object should never be able to move further than its max speed if it moved straight along one axis, the magnitude basically.
The magnitude should also scale depending on how far along the acceleration has come, for each axis separately, not assuming that it's always at max speed. For example, the acceleration may be at 90% of max speed along the X axis and only at 45% for Y.
Hope this makes sense.  :o

How can I get the XY coords. of this point?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15403
  • Official Playmaker Support
    • View Profile
Re: Angled movement xy coords.
« Reply #1 on: December 02, 2019, 01:09:35 AM »
Hi,

 the xy coord will be the direction*speed expressed from the local player transform into a world position.

use TransformDirection actions to get it.

https://docs.unity3d.com/ScriptReference/Transform.TransformDirection.html

Bye,

 Jean



Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Angled movement xy coords.
« Reply #2 on: December 02, 2019, 12:27:58 PM »
Hmm, I don't think that's right, diagonal movement looks too fast. Also, in your link it says that it does not take scale into account and that you should use TranformPoint for that. So I tried that and it would just launch the object in an insane speed. So I don't know what else to do.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15403
  • Official Playmaker Support
    • View Profile
Re: Angled movement xy coords.
« Reply #3 on: December 03, 2019, 01:25:44 AM »
Hi,

 yes, if you are using inputs, becausetyhe diagonal of 1 and 1 is greater than 1 ( you draw a square, not a circle, so magnitude is not consistent).

 simply, normalize your direction, and then multiply it by the speed, then you'll get speed consistency across all directions

Bye,

 Jean

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Angled movement xy coords.
« Reply #4 on: December 03, 2019, 08:07:26 AM »
I must be stupid or something because every time I try to do that the movement becomes messed up. You are talking about the normalize vector action right?

Do you mind giving a step by step explanation how to get a normalized direction to put into TransformDirection?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15403
  • Official Playmaker Support
    • View Profile
Re: Angled movement xy coords.
« Reply #5 on: December 13, 2019, 06:01:49 AM »
Hi,

 sure: here's a video https://imgur.com/qMo3gwa



Bye,

 Jean

Mupp

  • Junior Playmaker
  • **
  • Posts: 69
    • View Profile
Re: Angled movement xy coords.
« Reply #6 on: December 17, 2019, 01:21:23 PM »
Thank you, this will be useful.