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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Keavon · Nov 10, 2010 at 05:05 AM · movementballspinmarble

Simulating Marble Blast Gold: A script to make a character as a marble roll forward, mouse turns screen?

Hello! I a big noob to Unity and scripting. I would like to make a game such as Marble Blast Gold, where the character is a marble (a ball). The marble should move forward and backwards with the A and S keys, and left and right with the A and D keys (this means roll, not move, I already have a script for movement). The space bar should also make the marble jump a defined amount each time the space bar is hit, where a tap and a long hold should be the same height, and holding space will let you jump multiple times. I know how to use the smooth follow on the camera on the marble, but the mouse needs to turn the point of view, affecting where forward is. Also I need the up and down keys to move the height angle from side/up to top, having a limit of directly on top and around 45 degrees. I would really appreciate it if there could be a traction/slip variable to define. I am sorry that I am asking for a whole script, but I am very bad at scripting. This would help me and others learn more about it, but I am also very open to any suggestions, too. [I am going to add a bounty to this tomorrow, but apparently it has to be 3+ days to do so, so bear with me until then. Answering it today would be helpful and I can mark the answer describing all things mentioned here with the bounty points tomorrow.] Thank you! -Keavon

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 Jesse Anders · Nov 10, 2010 at 07:20 AM 0
Share

I think if you just want a complete script, your best bet might be to hire someone to write it for you, or try the 'Collaboration' forum and see if you can get a programmer involved in the project. Someone might be generous and post a complete script here, but that's not really what Unity Answers is geared towards. Of course if you have a specific question about how to write the script, you can always ask here or on the forums, and people will likely be more than happy to help.

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Wiki

Answer by JDonavan 1 · Nov 12, 2010 at 03:53 AM

You might start with the roll a ball example Unity Technologies provides... http://unity3d.com/support/resources/example-projects/iphone-examples.html

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 Keavon · Nov 12, 2010 at 04:49 AM 0
Share

Thank you for your reply. It says iPhone, but does it work cross-platform? I'll try it out now.

avatar image JDonavan 1 · Nov 12, 2010 at 12:49 PM 0
Share

For what you're looking for I imagine it's about as simple as changing which axis you're checking against.

avatar image Keavon · Nov 13, 2010 at 12:11 AM 0
Share

Err... It isn't relevant at all. Sorry. I tryed to modify the script but it has nothing to do with that, only to do with rolling, no force, since it is using the tilt sensor. D:

avatar image
0

Answer by supersm64fan · Jul 15, 2015 at 10:51 AM

This is what I use for movement.

 using UnityEngine;
 using System.Collections;
 
 public class MarbleControl : MonoBehaviour {
 
     public float movementSpeed = 6.0f;
     
     void Update () {
             Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * movementSpeed) + (Input.GetAxis("Vertical") * Vector3.forward *movementSpeed);
         movement *= Time.deltaTime;
             GetComponent<Rigidbody>().AddForce(movement, ForceMode.Force);
     }
 
     void OnTriggerEnter  (Collider other  ) {
         if (other.tag == "Pickup")
         {
             MarbleGameManager.SP.FoundGem();
             Destroy(other.gameObject);
         }
         else
         {
             //Other collider.. See other.tag and other.name
         }        
     }
 
 }


Here is a jump script.

using UnityEngine; using System.Collections;

public class JumpScript : MonoBehaviour { public float jumpForce;

 private float jumpHeight;
 private bool isGrounded ;
 private Vector3 jump;
 
 void Update()
 {
     jumpHeight = Input.GetAxis("Jump");
     jump = new Vector3(0.0f, jumpHeight, 0.0f);
     
     if(Input.GetButtonDown("Jump") && isGrounded)
     {
         GetComponent<Rigidbody>().AddForce(jump * jumpForce, ForceMode.Impulse);
         isGrounded = false;
     }  
 }
 
 void OnCollisionEnter()
 {
     isGrounded = true;
 }
 

}

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

2 People are following this question.

avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

CharacterController unexpectedly moving up 0 Answers

Detecting which way my mouse is moving the most 1 Answer

How to create icy floor? c# 1 Answer

Quaternion.FromToRotation misunderstanding 2 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