How do I lock 2-d object's orientation when it is moveable
I have a 2-d object that can move in the x and y axis only, but the problem is that when it catches on a corner of a wall, the object can rotate on its axis. I have used a gyroscope to maintain the orientation of the object after it has collided with a corner but I feel it can make the gameplay annoying.
Is there a way for me to lock an orientation for an object to prevent it from rotating at all? (I need the object to be collidable)
-
You could try using tags and look at rotators set to full strength and high speed.
Place the tag/tags along the axis of movement and the look at rotator will try and keep the object facing the correct direction (towards the tag). -
Unfortunately it doesn't solve the problem since the object starts vibrating rapidly.
I tried different combinations of speeds and using tags in the y and x axes but no luck.
I could get around this issue if there was a way to create a barrier for the player without using an invisible sculpt to block their path but I'm not sure how to do that. -
I've seen the vibration thing before too, I reduced it by adding a gyro at full power and full damping but did not fully get rid of it.
If your game is 2D in the X and Y you could use trigger zones to stop the player moving too far in any direction.
For example let's say you are moving left to right and you want to limit how far to the right you can travel. You could place a trigger zone and set it to look for a tag called right.
Now place a tag called right on the object. Wire the output of the trigger zone into a 'not' gate and the output if the 'not' gate into an 'and' gate. Also wire the right directional output of the left analog stick into the 'and' gate.
The output of the 'and' gate is wired to a mover set up to travel left to right.
Now when you press right on the stick the object moves right until the trigger zone detects the object and it stops. You can still move in the other three directions but not any further right.
You can set up four systems, one for each direction and maybe use wireless transmit & receive to reduce the number of wires if you plan on having a lot of trigger zones. Hope this helps -
I tried this method and it works much better! Thanks for the help :) don't know if it has been mentioned to MM before but it would be nice if the trigger zone can be made in to a custom shape so that you didn't require multiple gadgets for one task.
-
Happy to help, glad it works for you. You can build a sculpt of any shape and in its tweak menu you can assign it one of a number of predefined labels.
I believe most things can be set to detect labels in the same way as tags and this gives you a custom trigger zone of sorts. -
Yeah I guess there's always a way to do something in dreams, it's just a matter of finding the right way
Войдите в службу, чтобы оставить комментарий.