Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Micah on April 09, 2018, 04:23:47 PM
-
Is there a way to Reverse or Invert Rotation values? I'm trying to make a projective reflect off walls etc. I have been able to do so with transform, get collision info, Get position and Vector3.Reflect, but the rotation remains the same. So I tried Get Rotation with Vector3.reflect but to no avail. Is there any solution to this?
-
hi.
To get the opposite from a float i do a multiply by -1
You could try this with a Vector 3 operator
-
Okay So I did it. But it seems my theory Didn't work. *sigh* Is there any other way to do reflection or ricochet and have the object face the direction it is traveling in?
-
Hi.
With a pong game i made, i made some physics materials and placed them in the colliders from the walls.
-
Yeah Yeah I've tried that and it works, the problem is the direction. The object doesn't "Face" the direction it is travel
ing in. So say there is an arrow pointing 55 degrees, when it bounces off the wall, instead of rotating and facing the new direction it is now moving.
I got another idea. I'll try "Get Angle to Target", then "float subtract", then "float multiply by -1" and use that value to rotate the object.
Edit: LMAO That failed miserably........
Edit: Okay, I'm goin to see if I can get the angle of the normal and use the angle and x by 2 to get the full ricochet angle. I'm not a genius at maths as you can see. I'm just spit balling.
-
You can try and get the direction that the object is heading, and then rotate it to face the correct way.
There is an action for that in my github, under projectiles: https://github.com/dumbgamedev/general-playmaker
(Download whole project, unzip, take out playmaker action you want).
While you object is flying, get the vector 3 position. Wait 1 - 2 frames. Then get again. Now you have position 1 and position 2. Use the get direction vector 3 action, to get the direction. Use this to rotate your object.
-
Okay. I've tried and tried, it rotates, but sadly it just doesn't rotate accurately.
-
right. So I revisited my original idea which will probably set the president for designing my game. I used math but separated horizontal surfaces (facing Y) and vertical surfaces (facing X). It works. However there is one problem. For the Horizontal surfaces, I am using a float compare to determine if the value is higher than 0. So if Float 1 (Y Rotation) is lower than Float 2 = Subtract by 100, if Float 1 is greater than float 2 = Add 100.
What am I doing wrong? Because if the Float 1 is -41 for example, it still acts as if it is greater than 0, like playmaker sees it as 41 instead of -41. I tried swapping Float 1 and float 2 but the Opposite happens.
-
Hi,
Have tested with some break points?
I don't think the issue is on the float compare action, but on the rotation value.
-
Okay I Put the transition to none so that I can see it. Yeah the rotation isn't -41 in the scene its something like 314.
-
hi,
Maybe you need to get the quaternion or euler angles and try with those values
-
Those values seem to be what the problem is. I need to be able to turn 314 into -41 otherwise the calculation wont work
-
Hi,
I looked a bit on the unity forums
and a solution i found was to check if greater than 180 and if so deduct 360 to get the -value like on the inspector.
But maybe you can try to compare if higher or lower that 180 instead of 0 ?
-
hmm yeah that works. I just need to calculate the rest.
-
Okay so I pretty much achieved the deflection/Reflection off surface mechanic. I feel like I've wasted a week, but I've done it. To a standard that I like as well. Was a mighty ball ache though. I've had to use a lot of math and the actions and events are all over the place.
(https://files.slack.com/files-tmb/T4K5M4D41-FA8RQAYNT-73f67de220/image_1024.png)
he reflections are not 100% accurate But it will have to do.