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 RangerOfTheRings · Feb 20, 2017 at 04:57 PM · error messageerror-cs1525

can someone help me with fixing these scripts

 public Slider WidthSlider;
 public GameObject tile;
 public GameObject end;
 public int width = 10;
 public int length = 10;

 List<GameObject> level;
 // Use this for initialization
 void Start () {
     level = new List<GameObject> ();
     CreateLevel (width, length);
 }

 public void ClearLevel()
 {
     int numberOfTiles = level.Count;

     while (numberOfTiles > 0) {

         Destroy (level [0]);
         level.RemoveAt (0);
         numberOfTiles = numberOfTiles - 1;
     }
 }

 public void Rebuild()
 {
     CreateLevel (width, length);
 }

 public void GetWidth()
 {
     length = Mathf.FloorToInt(WidthSlider.value);
 }

 public void CreateLevel(float Width, float Length)
 {
     ClearLevel ();
     for (int x = 0; x < Width; x = x + 1) {
         for (int z = 0; z < Length; z = z + 1) {
             GameObject newTile = Instantiate (tile);
             Vector3 newPosition = transform.position +new Vector3 (x, 0, -z);
             newTile.transform.position = newPosition;
             level.Add (newTile);
         }
     }
     GameObject newEnd = Instantiate (end);
     Vector3 endPosition = transform.position +new Vector3 (Mathf.CeilToInt(Width/2)-0.5f, 0, -(Length+5)+0.5f);
     newEnd.transform.position = endPosition;
     newEnd.transform.localScale =  new Vector3 (Width, 1, 10);
     level.Add (newEnd);

 }
 // Update is called once per frame
 void Update () {
 
 }

} /// script 2 using UnityEngine; using System.Collections;

public class RandomColor : MonoBehaviour {

 Material myMaterial;
 public Color currentColor = Color.green;
 float nextSwitch = 0;
 public int thing = 0;
 public Collider BlackCollider;
 public float switchTime = 3;
 // Use this for initialization
 void Start () {
     MeshRenderer myRender = GetComponent<MeshRenderer> ();

     myMaterial = Instantiate (myRender.material);

     myRender.material = myMaterial;
     myMaterial.color = currentColor;
 }
 
 // Update is called once per frame
 void Update () {
     if (Time.time > nextSwitch) {
         nextSwitch = Time.time + switchTime;
         currentColor = NewColor();
         myMaterial.color = NewColor();
     }
 }
 Color NewColor (){

     float dice = Random.value;
     int choice = 0;


     if (dice > 0.85f) {
         choice = 1;
     } else if (dice > 0.8f){
         choice = 2;
     } else if (dice > 0.7f){
         choice = 3;
     }

     thing = choice;
     //Random.Range (0, 5);

     switch (choice) {
     case 0:
         BlackCollider.enabled = false;
         return Color.red;
         break;
     case 1:
         BlackCollider.enabled = true;
         return Color.black;
         break;
     case 2:
         BlackCollider.enabled = false;
         return Color.blue;
         break;
     case 3:
         BlackCollider.enabled = false;
         return Color.green;
         break;
     case 4:
         BlackCollider.enabled = false;
         return Color.yellow;
         break;
     case 5:
         
         return Color.magenta;
         break;
     }
     return Color.white;
 }

} // script 3 using UnityEngine; using System.Collections;

public class ColorEffect : MonoBehaviour {

 // Use this for initialization
 void Start () {
 
 }

 void OnCollisionEnter(Collision col)
 {
     RandomColor colorCube = col.gameObject.GetComponent<RandomColor> ();
     if (colorCube != null) {




         if (colorCube.thing == 2) {
             BlueEffect ();

         }
         if (colorCube.thing == 3) {
             GreenEffect ();
         }



     }
 }

 // Update is called once per frame
 void Update () {
 
 }

 void BlueEffect(){
     this.transform.position =  this.transform.position - (Vector3.forward*4);
     Debug.Log("BLUE");
 }


 void GreenEffect(){
     this.transform.position =  this.transform.position + (Vector3.forward*4);
     Debug.Log("You Dead bro");
 }
 void RedEffect(){
     
 }

} // script 4 using UnityEngine; using System.Collections;

public class PlayerWalk : MonoBehaviour {

 public float speed;

 private Rigidbody rb;

 void Start ()
 {
     rb = GetComponent<Rigidbody>();
 }

 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis ("Horizontal");
     float moveVertical = Input.GetAxis ("Vertical");

     Vector3 movement = (transform.right*moveHorizontal) + (transform.forward*moveVertical);

     rb.AddForce (movement * speed);
 }

}

Comment
Add comment · Show 1
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 jwulf · Feb 20, 2017 at 05:15 PM 1
Share

I would suggest rena$$anonymous$$g the variable "thing" to "entity" and the variable "width" to "tomatoJuiceCoefficient". Everything else looks fine to me.

Or did you mean by "fixing" that there are errors in the script / they are not doing what you want them too? Then please, be so incredibly kind to explain your problem precisely and maayyybee pleeaase even use the code-tags for the source code correctly so they are more readable.

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

94 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 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

ERROR CS 1525 Please help me!! 1 Answer

Hi im getting this error in my script Assets/MouseManager.cs(11,27): error CS1525: Unexpected symbol `Vector3' 2 Answers

What i can do with Type Load Exception Unity3d 0 Answers

c# Unreachable code detected 2 Answers

how do i fix this its not knownig UpdateUI 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