playMaker

Author Topic: Move to given degree  (Read 1720 times)

Stagg

  • Playmaker Newbie
  • *
  • Posts: 2
Move to given degree
« on: February 04, 2017, 08:28:44 AM »
Hello,

I'm working on a spaceship game and I'm trying to get an object to rotate to a given angle. For example, I press E and the ship rotates 5 degrees along the x axis. I've been trying for most of the day now and I can figure it out.

I'm assuming it would be a quaternion euler or quaternion moveto, but can't figure either out.

Any help would be amazing.

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Move to given degree
« Reply #1 on: February 05, 2017, 02:37:50 PM »
Can you not use transform.rotate? (There should be an action)

transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime); 
« Last Edit: February 05, 2017, 02:42:08 PM by elusiven »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Move to given degree
« Reply #2 on: February 06, 2017, 01:28:59 AM »
Hi,

 I think what he means is rotating to a specific angle, and not at a constant speed right?

If you can confirm this, then I can further help you. Typically, you are right using quaternions will be good. but you can also get away with animating a float from 0 to 5 ( or what ever target), and then inject that on the transform rotation axis of your choice, that works fine.

I am also working on a new custom action to animate a float like MoveTowards action ( Unity has the same moveTowards for floats, not just vector3), that woul dbe also a good way to go about this. Watch out on my twitter account for some news on this ( coming up either today or tomorrow).


 Bye,

 Jean

Stagg

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Move to given degree
« Reply #3 on: February 19, 2017, 12:57:01 AM »
So this is what I have scripted, and it more or less works for now.

I was just trying to make it work in playmaker.

public class Controller : MonoBehaviour {
    public Transform target;
public float speed;
void Update()
{
    float step = speed * Time.deltaTime;
    transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, step);
}
}

The target is controlled by gui sliders right now and the below script.

        transform.rotation = Quaternion.Euler(-Rot_X, -Rot_Y, -Rot_Z);

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Move to given degree
« Reply #4 on: February 21, 2017, 04:02:42 AM »
Hi,

 this script is totally feasible in PlayMaker, there is an action for each of the api function you use. What's not working when you try to do that in PlayMaker?

 Bye,

 Jean