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 /
avatar image
0
Question by Impostor Studios · Apr 29, 2016 at 07:34 PM · rotationrandomrandom.range

Rotation Bug

so im pretty new to coding and unity and I was wondering if any of you could help me. I have written this code which works but will also not work at all. (i dont get any error codes either) it will either work or it won't there is no inbetween. I was wondering if any of you could tell me what I need. I'm thinking its a bug because like I said it works... sometimes. what the code is meant to do is chose between different blocks and instantiate blocks with random 90degree rotations. The only thing that i'm having problems with though is the rotation of the blocks. I've added a bad drawing. each square is a block with a shape in the middle and those are the rotations I want. i'ts kind of hard to explain but hopefully someone can help. I've been working on this game for a long time now and I've just about completed it eseides this rotation bug. HELP!!!

alt text

using UnityEngine; using System.Collections;

 public class WallGenerator : MonoBehaviour {
 
     //public GameObject wall;
     public Transform generationPoint;
     public float distanceBetween;
     private float wallWidth = 1;
     int ranNum;
 
 
 
     public GameObject[] theWalls;
 
     private int wallSelector;
 
 
     // Use this for initialization
     void Start () {
 
         ranNum = Random.Range (0, 3);
 
 
     }
     
     // Update is called once per frame
     void Update () {
 
 
 
         if(transform.position.x < generationPoint.position.x) 
         {
             transform.position = new Vector3 (transform.position.x + wallWidth + distanceBetween, transform.position.y, transform.position.z);
         
             wallSelector = Random.Range (0,5);
 
 
 
 
 
             Instantiate (theWalls[wallSelector], transform.position, transform.rotation);
          transform.Rotate(ranNum*90, 0, 0);
 
             }
 
         }
 
 
 }
 


blockexample.png (10.7 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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Random Speed to an Object Rotation 0 Answers

How can I randomly create a number and then delete it to stop repeating 3 Answers

Reseting rotation of a random turret 1 Answer

java scrip, dice throw at a random rotation and force? 1 Answer

Random between -1 and 1 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