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 Nosmo · May 24, 2019 at 04:53 PM · mobilerestartphonerestart gameplaying

My game keeps restarting at random

Im almost done with my game, but I've discovered that when i play it on my phone it restarts at random periods for no reason.

Has this happens to any of your guys in the past and how did you solve it?

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 akaBase · May 24, 2019 at 05:47 PM 0
Share

You can be pretty sure that you have a bug somewhere in your code causing this.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nosmo · Jun 10, 2019 at 12:27 AM

I worked it out that 5 seconds (the restart time) after the bullet is destroyed the game restarts.

When my character is going at speed setting 5 and I fire, that's when it goes pear shaped.

But when the characters speed is set to 0 and i fire it doesn't restart. Also any speed setting after 3 and the game restarts when I shoot,

the player is destroyed instantly when i set the speed to over 40.

This is my movement script: does anyone have suggestions?


using UnityEngine; using UnityStandardAssets.CrossPlatformInput;

public class PlayerL2R : MonoBehaviour {

 private CharacterController charController;
 private Vector3 moveVector;

 public float forwardSpeed = 5.0f;
 public float horizontalSpeed = 5.0f;

 private GameObject Player;

 // Start is called before the first frame update
 public void Start()
 {
     charController = GetComponent<CharacterController>();
 }

 // Update is called once per frame
 public void Update() //addition
 {
     MovePlayer();   
 }

 public void MovePlayer() //addtion
 {
     moveVector = Vector3.zero;

     moveVector.x = CrossPlatformInputManager.GetAxis("Horizontal") * horizontalSpeed;  //left-right

     moveVector.z = forwardSpeed;  //forward

     charController.Move(moveVector * Time.deltaTime);
 }

}

Comment
Add comment · Show 1 · 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 akaBase · Jun 10, 2019 at 11:12 AM 0
Share

Sounds like you are restarting if the Player collides with the bullet.


You should check what the bullet is colliding with, you can use CompareTag to test which object has been hit, also I advise making use of Physics Layers.

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

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

Unity phone game: Would it be possible to access the camera/light sensor to get the amount of light? 0 Answers

What are the best android phones for developing games in unity3d? 1 Answer

How do I make Game Over text stay enabled for a few seconds before the Application Load function runs? 1 Answer

Simple Restart not working 0 Answers

Record video using phone's (mobile device's) camera 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