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 Maeva5 · Apr 26, 2018 at 05:19 PM · bugunity 2dvideo game

How can I make this script work ?

I wanted to create a script to make the camera move after we entered in a box collider. However I'm not very good in programming and I tried to follow another script but it doesn't work, Can somebody help me ? Here is the script. For information, the debug.log doesn't work. Thanks for answering !

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class CameraShake : MonoBehaviour { private bool isShaking = false;

 private float baseX, baseY;
 private float intensity =0.1f;
 private int shakes = 0;


 void OnTriggerEnter2D (Collider2D other) {

     if (other.gameObject.tag == "Player") {
         isShaking = true;
         Debug.Log ("hello");
     }
 }
 void Start ()
 {
     baseX = transform.position.x;
     baseY = transform.position.y;


 }
     
     
     void UpDate () {
     if (isShaking = true) {
         float randomShakeX = Random.Range (-intensity, intensity);
         float randomShakeY = Random.Range (-intensity, intensity);

         transform.position = new Vector2 (baseX + randomShakeX, baseY + randomShakeY);

         shakes--;
     }
         if(shakes<=0)
         {
             isShaking = false;
             transform.position = new Vector2(baseX, baseY);
         }
     }
     


 public void MinorShake(float in_intensity)
 {
     isShaking = true;
     shakes = 10;
     intensity = in_intensity;
 }

 public void LongShake(float in_intensity)
 {
     isShaking = true;
     shakes = 100;
     intensity = in_intensity;
 }

}

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 yaezah · Apr 26, 2018 at 05:32 PM 0
Share

$$anonymous$$ight want to change void UpDate to void Update first and see if that was the problem since it's case sensitive

avatar image Maeva5 yaezah · Apr 26, 2018 at 05:56 PM 0
Share

Thanks for your answer ! I'm french and I'm not very good in english so I'm not sure to understood well your advice, but If i understood well i remove the void Update at the first top of the script but it still doesn't work :/

avatar image Hellium Maeva5 · Apr 26, 2018 at 06:17 PM 0
Share

yaezah indique que le nom de la fonction est Update et non UpDate. C# est sensible à la casse des caractères.

Show more comments
avatar image Maeva5 yaezah · Apr 26, 2018 at 06:59 PM 0
Share

Oh yes you were right it was the problem ! Thank you very much for your help !

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

89 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

Related Questions

2D Platformer Bug 0 Answers

Possible bug in unity touch phase for android ? 1 Answer

Problem with sound 0 Answers

How to stop enemy AI from vibrating when tracking y component 0 Answers

How can i give time to execute the change of a sprite in my script? 1 Answer


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