Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ashwhite · Apr 02, 2016 at 06:48 PM · rotationcollisiongravitymergeplaymaker

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

alt text

block-alignment-feature.jpg (75.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ricardo_arango · Apr 12, 2016 at 02:39 PM

If the logic that you need is for detecting if the two objects start colliding, you can use the OnCollisionEnter callback : http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

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 : http://docs.unity3d.com/ScriptReference/Collider.OnCollisionStay.html. 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: http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html, OnTriggerStay, OnTriggerExit.

This tutorial from PlayMaker may help : https://www.youtube.com/watch?v=BYwkd80T5Zk&list=PLC759306A1E692A10∈dex=4&nohtml5=False

And this page from PlayMaker's the docs : https://hutonggames.fogbugz.com/default.asp?W30.

For specific help with PlayMaker you should try PlayMaker's forums : http://hutonggames.com/playmakerforum/index.php

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ashwhite · Apr 12, 2016 at 06:29 PM

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):

alt text

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


slice-sequence.jpg (154.9 kB)
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ricardo_arango ♦♦ · Apr 12, 2016 at 07:13 PM 0
Share

That is correct, the trigger would be part of the falling object. If the two triggers are touching when the piece falling contacts the piece on the top of the stack of pieces, then you could say that the piece is correctly rotated. If the triggers are not touching each other, then it's not correctly oriented.

There isn't one single way to solve this problem by the way. This is one way that I think should be easy to set up, with prefabs, triggers and a few scripts.

Triggers attached to pieces

67880-slice-sequence.jpg (88.8 kB)
avatar image ashwhite · Apr 12, 2016 at 08:19 PM 0
Share

Thanks for the confirmation @ricardo_arango. I had already tried this but couldn't workout how to execute the trigger that is stuck to the falling object. Can you help me with that please?

Thanks,

Ash

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

70 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to create "Gravity Roads" in a FPS? 3 Answers

Copy collision object position (Or just "fly" a little bit) 0 Answers

Having trouble rotating around transform.up 0 Answers

Implementing gravity in 2D game 0 Answers

How to stop object rotation when FPSController collides with object? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges