playMaker

Author Topic: Object Rotation with Joystick, but not through Smooth Look At Direction  (Read 731 times)

Chutson7221

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Hello,

I'm a 3D artist and just getting into using Playmaker. Right now I'm working on a 3D twin-stick tank shooter and I'm trying to figure out if a movement script can be recreated with Playmaker. The idea is to use the left joystick of a controller to tanslate the player on its local Z and rotate the player to face the direction of the joystick. I have a script from a friend, which had been setup using InControl, and it does handle the movement exactly how I would like it to, though I want to move away from any extra scripts.

I've tried using Smooth Look At Direction and it does a similar movement but doesn't seem to be near as precise (usually smoothly shifting snapping to 45 degree angles on the joystick, as well as additional movement when I am not moving the joystick).

The code I have works though I would like to build it as an FSM, both so I can learn the maths behind it as well as be able to utilize it for AI movement in the future and to modify the player's movement in-game.

Thanks!
« Last Edit: October 02, 2018, 07:30:28 AM by Chutson7221 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4611
    • View Profile
    • jinxtergames
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #1 on: October 01, 2018, 11:40:12 PM »
Hi.
Actually the native build-in controls are not really good, that's why most people use 3rd party assets like rewired, incontrol and so on.

just a sidenote :
it is not allowed to share an asset if it is one per seat.
If you do not own an asset (like inControl for example) you are not allowed to use that.
So be careful with that :)

Chutson7221

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #2 on: October 02, 2018, 07:09:26 AM »
Gotcha, I'll watch out for that from here on. Thanks!  :)

Hopefully I can still get something figured out to get the movement I had described, just without any other plugins.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4611
    • View Profile
    • jinxtergames
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #3 on: October 03, 2018, 02:41:29 AM »
Hi.
Maybe you can use 'Get Axis' action to get the controller 'movement' (horizontal for left/right or set custom controls in 'Edit/Project Settings/Input)

Then multiply by the degrees you wish to limit it to.
You can play around with the gravity and sensitivity to make is smoother if you wish.

Then use this to set the rotation on your object.

miguelfanclub

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #4 on: October 03, 2018, 07:12:41 AM »
I did a mouse look effect with controller here:

https://hutonggames.com/playmakerforum/index.php?topic=19259.msg83931#msg83931

Its using rewired, but you can swap that action for a "get axis" from the mouse / controller

Chutson7221

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #5 on: October 03, 2018, 11:12:37 AM »
djaydino,

I've figured it out for the most part. Mentioning using Get Axis made me think through it again. One of those kind of things that if I thought about it a bit more, I would've gotten it. I managed to get the same setup with the corresponding actions. Thanks for the help! I've attached a screenshot of the action setup.
The only issue now is not having the object rotate back to zero when I stop moving the joystick.


miguelfanclub,

Thanks for the reference. I'm not using rewired right now, but I'll keep this in mine should I use it in the future.

miguelfanclub

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: Object Rotation with Joystick, but not through Smooth Look At Direction
« Reply #6 on: October 03, 2018, 03:49:53 PM »
Yes, but if you swap my rewired get axis for yours should work the same.

-Edit-
Oh, now I see how you did it. Great, thanks for sharing.