Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Feb 09, 2015 at 10:18 AM by HarshadK for the following reason:

Too subjective and argumentative

avatar image
0
Question by EscTheCtrl · Feb 09, 2015 at 07:51 AM · movementmobiledirectionpuzzlechanging

Changing the direction of an object using another object.

So I have a little puzzle/like game I've been working on, that involves you changing the direction of tiles so that it will shoot the balls towards their goals, but I need help getting the tiles to change the direction of the ball. The "direction changers" are hexagons with arrows inside of them. The Issue I'm having is i want the balls to be able to enter the hex along the red lines, go to the center of the tile, then exit out of the tile from the green line. alt text

so the ball code is called "Sprite" and is posted below.

 var SpriteColor : int;
 var speed : float = 1;
 
 function Start () 
 {
     SpriteColor = Random.Range(1, 13);
     
     //make it check to see what colors of hexes there are and only use those colors??
 }
 
 function Update () 
 {
     //Code to change sprite colors has been removed to shorten this script up a bit.
         
     transform.Translate(Vector3(-1, 0, 0) * speed * Time.deltaTime);
 
 }
 
 function OnBecameInvisible()
 {
     Destroy (gameObject);
 }

and here is my ArrowScript which controls the rotation and various other things within the hextiles.

 var TileState : int;
 static var TileRotation : int;
 
 var EdgeTile : boolean = false;
 
 var HexArrow : GameObject;
 var Arrow : GameObject;
 
 function Start () 
 {
     TileState = Random.Range(0, 10);
     TileRotation = Random.Range(1, 6);
     Rotate();
 }
 
 function Awake()
 {
     spriteDir = GetComponent(Sprite);
     
 }
 
 function Update () 
 {
     if(TileState == 1 || TileState == 10 && EdgeTile == false)
     {
         FixedTile();
     }
 }
 
 function FixedTile()
 {
     //makes this tile unable to be rotated by user Input.
     HexArrow.gameObject.SetActive(false);
     Arrow.gameObject.SetActive(true);
 }
 
 //my failed attempt at trying to work something out with getting the sprite/ball to change direction when it entered the hex tile.
 var spriteDir : Sprite;
 
 var DirX : float;
 var DirY : float;
 
 function OnCollisionEnter(collision : Collision)
 {
     if(gameObject.tag == "Ball")
     {
         transform.Translate(Vector3(DirX, DirY, 0));
     }
     
     
 }
 
 function Rotate()
 {
     //Randomly rotates the tiles facing a random direction in intervals of 60 degrees at the start of a game.
         
     if(TileRotation == 1)
     {
         transform.Rotate(Vector3(0, 0, 0));
     }
     
     if(TileRotation == 2)
     {
         transform.Rotate(Vector3(0, 0, 60));
     }
     
     if(TileRotation == 3)
     {
         transform.Rotate(Vector3(0, 0, 120));
     }
     
     if(TileRotation == 4)
     {
         transform.Rotate(Vector3(0, 0, 180));
     }
     
     if(TileRotation == 5)
     {
         transform.Rotate(Vector3(0, 0, 240));
     }
     
     if(TileRotation == 6)
     {
         transform.Rotate(Vector3(0, 0, 300));
     }
 }

what I'm wanting to do, and cannot figure out is how to make the hex tile script change the direction of the ball script according to the tileRotation. Could anyone help me out?

hexarrowtest.png (13.5 kB)
Comment
Add comment · Show 5
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 Joyrider · Feb 09, 2015 at 10:04 AM 0
Share

Too subjective, UnityAnswers is for resolving a very specific issue not to start a discussion. The forum is meant for this kind of topics, so post this on the forum. This should never have passed moderation.

avatar image HarshadK · Feb 09, 2015 at 10:08 AM 0
Share

@Joyrider he has 26 karma so his question never went into moderation queue.

avatar image Joyrider · Feb 09, 2015 at 10:11 AM 0
Share

@Harshad$$anonymous$$ $$anonymous$$y bad ;) Can you close the question?

avatar image HarshadK · Feb 09, 2015 at 10:17 AM 0
Share

@EscTheCtrl this question is being closed for being subjective but you can edit the question to provide additional information like any code you have written or something specific then we can re-open this question.

avatar image EscTheCtrl · Feb 10, 2015 at 05:15 AM 0
Share

@Harshad$$anonymous$$ Better?

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Stop object movement in 1 direction along axis 1 Answer

How do I do a double Floating joystick? (Direction and movement (one for each))? 0 Answers

Transform position of an object at particular angle/direction 3 Answers

[C#] Using the same input option to start and stop movement 2 Answers

How to move a game object by moving a device? 2 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