how can I align a rotating block that falls onto another with the correct face?

Hi all,

This is my first post on Unity and my first venture into gaming so please excuse my lack of terminology or logic behind my questioning…

The premise of this particular scenario is that a rotating object is falling from the sky onto an existing, static object. Both objects have icons on each face and the aim is for the user to align the correct face with both static and falling objects to initiate the next falling object sequence.

The control is simple in concept - a single tap gesture to act as a counter force against the gravity applied to the falling object (think flappy bird logic only on a vertical, linear path or a thruster in doodle jump).

When the spinning object faces are in line with the static objects faces the user will reduce the thrust with the target of getting the two objects to collide in correct alignment. Please see attached image for example.

I have the objects, gravity and thruster working.

I’m just unsure how to execute the collision logic. My guess is that I need only define one point within a certain area and not each face but I don’t know where to start. I’m also not very familiar with coding (please don’t judge me too much) and have been using ‘Playmaker’ to get me as far as I have.

Any help would be hugely appreciated and if I’ve not been clear enough I’d be happy to try and explain further.

Regards,

Ash

If the logic that you need is for detecting if the two objects start colliding, you can use the OnCollisionEnter callback : Unity - Scripting API: Collider.OnCollisionEnter(Collision)

You can also use OnCollisionStay if you want to know if the objects continue to be in contact, and for instance measure how long they have been touching : Unity - Scripting API: Collider.OnCollisionStay(Collision). You would have to add a timer that would start counting when OnCollisionEnter is called, and updated in every update of OnCollisionStay.

If you want to detect the collisions much earlier (before the objects are visibly touching) you can use a trigger that is larger than the cube object, and use trigger collision events: Unity - Scripting API: Collider.OnTriggerEnter(Collider), OnTriggerStay, OnTriggerExit.

This tutorial from PlayMaker may help : 03 - Triggers - YouTube

And this page from PlayMaker’s the docs : Collision Event.

For specific help with PlayMaker you should try PlayMaker’s forums : Playmaker Forum - Index

If you want to know if the cubes have the same orientation, you can compare the orientation of both objects and see if they match:

transform.rotation == targetObject.transform.rotation

You would need to design your objects in way that when the rotation is equal, the symbols align.

Or you could add a trigger for each face, with a script attached to each face that exposes a variable in which you can set the name/id of the symbol of that face. When two triggers are in contact, you can compare the symbols of the faces that are in contact.

Thanks so much for getting back to me @ricardo_arango . I think I need to be more specific with the collision points rather than a generic object collision as the side faces need to align correctly in order to initiate another falling block.

You would need to design your objects
in way that when the rotation is
equal, the symbols align…

Or you could add a trigger for each
face, with a script attached to each
face that exposes a variable in which
you can set the name/id of the symbol
of that face. When two triggers are in
contact, you can compare the symbols
of the faces that are in contact.

The design has evolved into something more visually complex however, it remains the same in game logic. The new objects will look similar to the below, including the same kind of sequence (think a low-poly object sliced up):

I’m curious as to how you would add a trigger to a face if that face is essentially part of a falling object/rigid body? I’ve not found a way of getting a trigger to “stick” to a rigid body yet. If you could explain further how I can achieve my game idea above I’d be very grateful.

I look forward to your response.

Thanks

Ash