Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cube Roller

Discussion in 'Scripting' started by Luke3671, Aug 2, 2015.

  1. Luke3671

    Luke3671

    Joined:
    Jul 6, 2014
    Posts:
    56
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    This is a very specific sort of game; I wouldn't expect to find a tutorial about how to do that specifically. Nothing in it is very hard, though, and the skills you need are well taught by all the other Unity tutorials. Spend a month or two doing those (really doing them, not just "watching" them), and then I bet you'll see how to make a game like this.
     
    Luke3671 likes this.
  3. Luke3671

    Luke3671

    Joined:
    Jul 6, 2014
    Posts:
    56
    True, I just needed now how to make cube go, left,right,up & down but rotate when pressing down the keys.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Well, you call transform.Rotate to rotate the cube (you want to rotate a little bit on each frame, i.e. each Update call). And then you'll probably want to also update the position too, so that the cube lifts up a little bit as it rolls. This is where all the middle-school math teachers whose students said "When will I ever need to use this stuff?" are now laughing. :) The height (Y position) of the cube describes a sine function as you roll, so you can use Mathf.Sin to calculate that.