Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Jtheme on January 01, 2013, 06:41:01 PM
-
I am trying to find a way to make a game object rotate on the x-axis in the location of the mouse pointer.
Any help or tips would be greatly appreciated!
-
Maybe I'm not explaining myself well enough. I am wanting to rotate an object exactly how the player rotates in the scene http://u3d.as/content/unity-technologies/angry-bots/2aL (http://u3d.as/content/unity-technologies/angry-bots/2aL)
-
Hi,
interesting question:
study this mouse drag action ( that let you know the position of the mouse in the 3d world on a plane)
http://hutonggames.com/playmakerforum/index.php?topic=272.0 (http://hutonggames.com/playmakerforum/index.php?topic=272.0)
using the resulting position with the above action, you can then use the action "Smooth Look at"
https://hutonggames.fogbugz.com/default.asp?W458 (https://hutonggames.fogbugz.com/default.asp?W458)
That's would be the right combination to begin with this.
bye,
Jean
-
Thanks Jean!
I have one more question. I'm not sure how to go about this at all.
How would I go about making an even when the object reaches Y-axis 180 and then another event when it reaches Y-axis 90?
-
Hi,
the angle is between what and what?
there is an action "Get angle to target":
https://hutonggames.fogbugz.com/default.asp?W494 (https://hutonggames.fogbugz.com/default.asp?W494)
Try this, and then simply compare the angle using "float compare" or float switch and then you can fire events like that.
bye,
Jean
-
Thank you, I'm pretty new at this. How exactly would I go about that?
-
Hi,
ok, please find a package attached where the gameObject will look at the mouse like on angrybots.
As for the angle events, I am still unsure what you are trying to achieve, so can you be more explicit?
bye,
Jean
-
To explain, I have a scene with a red cylinder with a blue cube as it's face. I have it's rotation following my mouse.
When my mouse gets in the angles of the blue area "event 1" for example it fires off an even. And when my mouse gets in the green area it fires off a different event.
(http://f.cl.ly/items/2a0D2y0W0E0S3g1l2S0p/Help.png)
-
Hi
I am by no means an expert at this, but if i was you, I would create an invisible game object at the green and blue area, and then make each of them a hitbox that covers the area where you want to trigger an event
then on the red cylinder that you are rotating, add a raycast to the front of it, and if it hits an object, make it store the name of that object in a variable - then use that variable to run a compare between the name of the object the ray hit, and the name of the actual box. If the names are the same, fire off an event.
Hope this helps
-Kozgal
-
reading through this again, what i said above would only work if the red object doesn't move (only rotates)
If the object moves as well as rotates, then i guess you use a get rotation action and save the rotation coords as a float or int and do a compare with a variable you set
I could give an example if you could explain what this is used for - is it the player thats able to move and if he looks to much to the side, something happens?
-
Yes it if for my player. When he looks to the side I'm wanting to trigger a unique animation.
-
hi,
Simply attach the collider to your player then. Have a trigger collider for the front section and a trigger collider for the back section, as the blue box rotates, you simply wait for trigger events and fire when entered.
bye,
Jean
-
Exactly what Jean said :) to explain it in "normal" words - you make two invisible gameobjects and parent them to the player (so they always follow the player) then you add collider components to both of those invisible gameobjects and check the "make trigger" button in the component menu. Now play around with position and size so that the two trigger boxes are located on the side of the character in the area you want to trigger an event. Make sure the trigger boxes only follow player position and not the rotation (otherwise when player rotates, the boxes will rotate with him and not be able to detect rotation at all)
When the triggerboxes are set, you can do 1 of 2 things;
Either add a 3rd trigger box to the front of the character that also rotates with character (so the box is always on the front of the character - like a reverse backpack) and make the side-triggers listen for collision with the front-trigger. This will detect that the character has turned to the side, and trigger an event (like your animation)
or
Do the same thing, but with raycast.
Add a raycast to the front of the character - detect if the raycast hits the side-trigger objects and if so, trigger an event
Hope this helps you understand Jeans pro lingo :)
-Koztheboss
-
I got it to work! Thank you to everyone that helped out!!! I've been trying to figure out how to do this for weeks.
-
glad to help :)