playMaker

Author Topic: rotate 360 over time [SOLVED]  (Read 6383 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
rotate 360 over time [SOLVED]
« on: September 03, 2015, 07:48:43 PM »
Hi

I have a game object which I want to rotate over a set period of time. I have this as a variable. I need the object to stop once it's reached 360 degrees

Any ideas how to achieve this as the rotate and Itween rotate don't work for my requirement.

Nick
« Last Edit: September 07, 2015, 08:11:07 AM by coxy17 »

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: rotate 360 over time
« Reply #1 on: September 03, 2015, 08:20:19 PM »
You could just time your rotation. I'm sure it is not the best way but it will work...
Rotation=AnglePerSecond(Time) or 360=A(T)

An example would be:

State 1 - rotate axis= 45, (since 45 goes into 360, 8 times the wait will be 8 seconds.) wait 8 seconds then send event next state.

State 2 - rotate axis = 0

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: rotate 360 over time
« Reply #2 on: September 03, 2015, 08:34:52 PM »
Sorry to double post, just noticed your time is a variable that you might want to adjust. Do this instead.

rotation = 360
time = whatever you want

state 1 - FloatDivide rotation/time, rotate axis = rotation, wait = time, finish event
state 2 - rotation = 0

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: rotate 360 over time
« Reply #3 on: September 04, 2015, 04:18:59 PM »
Hi.

It's OK.  Thanks for the advice. I'll give it a go. I'm just after my player rolling over when a key is pressed once and continuously when held so I think your plan will work.  I'll let you know if it goes ok. Not great at this yet.

Cheers nick.

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: rotate 360 over time
« Reply #4 on: September 04, 2015, 06:37:28 PM »
hey,

i have tried your idea and it rotates but player doesnt stand back up completely straight, i want the player to roll and stand back in the up position. Ive tried messing around with FixedUpdate and real time settings after in case something worked. But noting does. Do you mind creating a small demo? its ok if not.

Nick

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: rotate 360 over time
« Reply #5 on: September 05, 2015, 12:41:53 AM »
So the game object you are trying to move is a character? Does it have a character controller or rigidbody? If it's a complicated 3d character I would animate the roll instead of scripting it. If that is the case there are probably physics/collision issues causing your character to not stand completely straight. If you attach some images or a video of whats going on myself or someone else will be better able to help you.

I've attached images of my test playmaker fsm, it rotates the owner which is a cube in my case 360 degrees on a keypress, and loops back into itself once finished...

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: rotate 360 over time
« Reply #6 on: September 05, 2015, 10:35:53 AM »
yes the game object is apart of my character, the player is the parent object and i have a small character which walks beside (so the object is a child) and has no collisions or RigidBody but the parent does. Sorry wasnt clear before.

I have attached my setup and ive found that it over turns by a fraction. Sometimes a big further. Not consistency.

Is it due to the parent object having a collision?



Nick

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: rotate 360 over time
« Reply #7 on: September 05, 2015, 02:23:26 PM »
Okay it definitely has nothing to do with collision or the player then. I had thought it might be bumping into other objects such as the ground. I tested this on my end and couldn't replicate your problem.  It should be working, however it's not so...

Check and make sure you are reseting the rotation variable to 360 and the objects rotation to 0 so that even if for some reason it over/under rotates by a fraction it will be forced to reset back at 0. Below is a screenshot of my state that does this. If your still having trouble I'll make an example for you next when I get a chance.

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: rotate 360 over time
« Reply #8 on: September 06, 2015, 02:38:23 PM »
Hi. I've triple checked and it still behaves strangely. I would really appreciate a test demo. When you have time :) cheers

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: rotate 360 over time
« Reply #9 on: September 06, 2015, 08:19:51 PM »
When I increased the speed and mashed the button to rotate I was finally able to replicate your problem.  I forgot to include the 'set rotation' transformation to 0 in the first state. That will solve your problem.  So you will have two actions affecting the rotation in your first state. 'Set Rotation' and 'Rotation'. Hope that helps, I included an example scene/package for you as well even though you probably won't need it now.

*You will need playmaker imported already into the game you test the package in.

Example package:
https://drive.google.com/file/d/0Bypf4VrrxKTza1d4RWZpX09OZjA/view

WebPlayer scene:
https://dl.dropboxusercontent.com/s/qi9f3my7cezwz55/ExampleCoxy.html
« Last Edit: September 06, 2015, 11:22:21 PM by Justin »

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: rotate 360 over time
« Reply #10 on: September 07, 2015, 08:10:54 AM »
Hi,

Thanks for explaining. it works great now! your help has been greatly appreciated!

Nick