Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 sephiroth111 · Aug 14, 2012 at 06:04 AM · c#flickering

Character flickering when moving

Hello to everyone. I have a problem, my character was flickering when moving, i don't know why. I'm confused why it was hapenning. here is my code for my character control:

 public class MyCharacterControl : MonoBehaviour 
 {
 private Vector3 moveDirection = Vector3.zero;
 public float Speed = 10f;
 public float JumpSpeed = 40f;
 public float Gravity = 40f;
 public float PlayerRotationRight = 80f;
 public float PlayerRotationLeft = -80f;
 

// Update is called once per frame

void Update () {

CharacterController control = GetComponent();

if (control.isGrounded)

{

  moveDirection = new Vector3(0, 0, Input.GetAxis("Vertical"));
  moveDirection = transform.TransformDirection(moveDirection);
         moveDirection *= Speed;
         if (Input.GetKey(KeyCode.D))
         {
             transform.Rotate(0, PlayerRotationRight * Time.deltaTime, 0);
         }
         if (Input.GetKey(KeyCode.A))
         {
             transform.Rotate(0, PlayerRotationLeft * Time.deltaTime, 0);
         }

}

     moveDirection.y -= Gravity * Time.deltaTime;
     control.Move(moveDirection * Time.deltaTime);

     //ANIMATION TESTING ONLY
 
     if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.DownArrow))
     {
         animation.CrossFade("01_Basic Run");
     }
     else
     {
         animation.CrossFade("Idle_01");

     }

} }

Here is my camera smooth follow to player:

 public class CameraFollow : MonoBehaviour 
 {
 public Transform Player;
 public int Distance = 0;
 public int CameraVertical = 0;
 public float CameraSmootFollow = 0.08f;

 private Transform playerCamera;
 private bool cameraSetup = false;
 private string buttonText = "";
 private Vector3 CameraDistance = Vector3.zero;

 void Start()
 {
     playerCamera = transform;
     
 }

 void Update () 
 {
     if (CameraSmootFollow >= 1)
     {
         CameraSmootFollow = 1;
     }
     else if(CameraSmootFollow <= 0)
     {
         CameraSmootFollow = 0;
     }
     playerCamera.transform.LookAt(Player);
     CameraDistance = new Vector3(Player.transform.position.x, Player.transform.position.y + Distance + CameraVertical, Player.transform.position.z - Distance);
     playerCamera.transform.position = Vector3.Lerp(playerCamera.transform.position, CameraDistance, CameraSmootFollow);

} }

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 DESTRUKTORR · Aug 14, 2012 at 02:30 PM 0
Share

It's probably from mesh overlap. Can we get a screenshot of the flickering? Or is it literally turning the mesh on and off?

avatar image electricsauce · Aug 15, 2012 at 01:33 AM 1
Share

The camera transform should probably be in lateupdate. Don't know if that will help though.

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

9 People are following this question.

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

Related Questions

default reference missing in prefabs 0 Answers

Cloud recognition in Vuforia 0 Answers

2D object flickers when it is in high speed in Unity 4.3 0 Answers

2D object flickers on moving Unity 4.3 2 Answers

How to destroy object forever? when i go to another scene and back to first, i want to that object stay destroyed! , Please !!!!  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