playMaker

Author Topic: Vector 3 add issue  (Read 1331 times)

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Vector 3 add issue
« on: August 14, 2021, 06:58:05 PM »
Hello,

I have a vector 3 add that adds 90 (degrees) to a rotation mechanic. It works for the first 2 rotations (adds 90 to 0, 0+90=90, and adds 90 to 90, 90+90=180) But whenever it adds 90 a third time it results in 270 in the variable (good) but -90 in the game object's rotation. You wouldn't think this would be a big deal since -90 degrees and 270 are the same on a circle, but it results in a weird jerking movement on the rotation. My game mechanic is that the whole level rotates whenever you hit a button (must be touching a wall to do this). Here is the FSM. I basically set the Vector 3 value to 0 (every frame). I was having an issue with this before and it seemed to help. I have two colliders on my game object (one left and one right). A trigger2d event sends an event depending which side was hit. Then it either adds -90 or 90 depending which side was hit. And it rotates the entire game. The camera and colliders are kept to 0. I tried posting about this in a different way before but I figured I'd start a new post so hopefully its clearer. I could try posting the entire FSM but it would take a bunch of screen shots so I figured this was easier. Thanks in advance for your help!

John Bassi

bigPalooka

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Vector 3 add issue
« Reply #1 on: August 15, 2021, 03:22:33 AM »
This is an issue you'll run into a lot with euler angles.

I would consider making 4 empty game objects, one for each target angle. Then when you want to add 90 degrees, tween your rotation to look at the next game object.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Vector 3 add issue
« Reply #2 on: August 15, 2021, 04:57:31 AM »
I feel like this was my first approach, unless I’m misunderstanding you. I previously set the rotation and it still happened. I’m not entirely sure what you mean by “tweaning your rotation to look at the next game object”. If you mean set the rotation on the z axis for tween rotation actions every time you rotate, then the problem still occurs. If you mean something else, please explain I’m all ears as I’ve been trying to get this to work for quite some time. Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Vector 3 add issue
« Reply #3 on: August 15, 2021, 11:12:49 AM »
Hi.
Maybe you can use Smooth Look At