Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Halo500 · Jul 22, 2015 at 08:23 AM · cameraimagehorror

Image Jumpscare in Front of Camera

Hello, I'm trying to make one of those cheap, really loud jumpscares where an image on a plane would be placed in front of the player camera, as a child, and wait for a certain amount of time, and the jumpscare would pop up again.

I've gotten everything down, but I'm wondering how I would achieve this effect at 0:30 (WARNING! IT IS A JUMPSCARE!)

where the image shakes frantically across the screen like so. Maybe a random offset float of some kind? Any help would be greatly appreciated! :)

Comment
Add comment · Show 2
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 Cherno · Jul 22, 2015 at 08:29 AM 0
Share

Yeah, a simple Coroutine that changes teh position of the image by a few pixels every few frames.

avatar image Halo500 · Jul 23, 2015 at 12:15 AM 0
Share

Thank you Cherno for confir$$anonymous$$g this with me! :)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Basen · Jul 22, 2015 at 09:19 AM

 IEnumerator Shake() {
         
     float elapsed = 0.0f;
     
     Vector3 originalCamPos = Camera.main.transform.position;
     
     while (elapsed < duration) {
         
         elapsed += Time.deltaTime;          
         
         float percentComplete = elapsed / duration;         
         float damper = 1.0f - Mathf.Clamp(4.0f * percentComplete - 3.0f, 0.0f, 1.0f);
         
         // map value to [-1, 1]
         float x = Random.value * 2.0f - 1.0f;
         float y = Random.value * 2.0f - 1.0f;
         x *= magnitude * damper;
         y *= magnitude * damper;
         
         Camera.main.transform.position = new Vector3(x, y, originalCamPos.z);
             
         yield return null;
     }
     
     Camera.main.transform.position = originalCamPos;
 }

This is the CameraShake Coroutine I use. Modify the damper and x and y floats for best results! GL and post your result as a video!

Comment
Add comment · Show 3 · 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 Halo500 · Jul 23, 2015 at 12:16 AM 0
Share

Hello Basen, thank you for being kind enough to share your CameraShake Coroutine. I'm getting one small error though when I try to use it: "The name `duration' does not exist in the current context"

avatar image Basen · Jul 23, 2015 at 07:52 AM 0
Share

Hey yeah sorry, duration is just a float you need to add. Its for how long the shake should persist.

So just

 float duration = 0.5f; 

for example

avatar image Halo500 · Jul 23, 2015 at 08:29 AM 0
Share

Oh, alright then. Just wanted to make sure it wasn't an extra part of your script. Thank you for your support Basen! ;)

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

24 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

Related Questions

Convert UI Image size and position to Camera viewport rec. 1 Answer

My unity image isn't showing up, what gives? 0 Answers

Images only render is centre is visible. 0 Answers

Setting an Image as Camera Background (Unity 4.6) 1 Answer

import video from camera 3 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