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
1
Question by Caolan · Jul 13, 2015 at 01:01 AM · cameracamera-movementscriptingbasicsgameplayfirst-person

How to do screenshake without influencing the transform of the camera?

I want to get a screen-shake effect on my main camera, It is a first person camera and it is set up to follow the 'player' object, is there another way to do screen-shake, without screwing with the camera's transform? because if I do that the player basically has to sit and wait for the screen-shake to be over, they can't move the camera while it is being shaken because the script I am using basically takes control of the camera's transform and plays with the values. This is very jarring and obviously not ideal.

Does anyone have any ideas, or any methods that they have used in their own games for screen shake as an effect for a moving camera controlled by the player?

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 meat5000 ♦ · Jul 12, 2015 at 01:59 PM 0
Share

You could mess with the viewport ins$$anonymous$$d.

2 Replies

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

Answer by troien · Jul 13, 2015 at 07:24 AM

Well, I think the best way is to actually influence the transform of the camera.

There would be 2 ways that I can think of atm of how you can achieve this. In these examples, I will call your script that takes over the transform of the camera "CameraController".

1:

  • Edit your CameraController in a way that it works with 2 Vector3's instead of the one of the Transform.

  • One of the Vector3's represends what used to be transfrom.position.

  • The other one represents the screen shake offset.

  • By combining these two values you should get a correct position that can be used by the camera transfrom.

2: (The easiest one)

  • Make the camera a child of an empty gameobject.

  • Move your CameraController script from your camera to this empty gameobject.

  • Add a Screenshake script to the camera and let it change the localposition of the transform.

This way you CameraController can still control the transfrom without problems, as the ScreenShake script will never influence the Transfrom of its parent. Another advantage is that you can simply work with localPosition and localRotation, which means you can work with an offset to the direction that the CameraController is facing.

Comment
Add comment · 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
0

Answer by Torigas · Jul 13, 2015 at 08:15 AM

You could write an image effect that jitters the screen. Not essentially good for performance but might be worth a try.

You can copy, say the grayscale image effect and add values like a float offset. You can add that offset to the u/v coordinates while reading the color info. Then in your image effect script you get a random value for your offset and set it in the image effect material.

Comment
Add comment · 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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I get a Capsule to move and rotate in the direction the cam is facing? 1 Answer

How to make the camera look ahead of the player when he is moving 2 Answers

how to modify this code to place it inside a car and move it along the car. 0 Answers

Regarding transform.position in the roll a ball tutorial 1 Answer

Camera movement and gun follow in unity 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