Move forward around object

Hi, Im new to unity and i am experimenting. I Want to make a character (just a cube atm) be able to walk around an object going against gravity.

The best example i can give is with the game Kula World, where the ball can move around some blocks. But when you jump off you fall as usual.

e.g. http://www.youtube.com/watch?v=Ol1usmZs9r8 (go to 3:40 to see what i mean)

What would i need to have to achieve this? a vector attached to my player to stick to the object?

I have managed to create this in Blender using Python but don’t fully understand Unity yet. Ive copied the full code so this includes the key controls (I’ve already done this in Unity)

If anyone could help with converting i would be most grateful!

from bge import logic, events
#from bge import render
from mathutils import Vector
from math import pi

tic_rate = logic.getLogicTicRate()

gravity = 20

turn_speed = 0.05
move_speed = 2.5
jump_force = 500.0

up_key = events.UPARROWKEY
down_key = events.DOWNARROWKEY
left_key = events.LEFTARROWKEY
right_key = events.RIGHTARROWKEY
run_key = events.LEFTCTRLKEY
jump_key = events.XKEY

class Translation:
    
    def __init__(self, own, sensors):
        self.own = own
        self.floor = own
        self.col_floor = sensors[1]
        self.velocity = Vector()
        self.rotation = Vector()
        self.force = Vector()
        self.gravity = Vector((0, 0, -gravity))
        self.normal = Vector((0, 0, 1))
    
    def keyboard(self, just_activated=1, active=2):
        events = logic.keyboard.events
        left = events[left_key] is active
        right = events[right_key] is active
        up = events[up_key] is active
        down = events[down_key] is active
        jump = events[jump_key] is just_activated
        move = up - down
        turn = left - right
        return turn, move, jump

    def get_normal(self):
        ori = self.own.worldOrientation
        start = self.own.worldPosition
        end = self.floor.worldPosition
#        render.drawLine(start, end, [1, 1, 0])
        hit_normal = self.own.rayCast(end, start, 1)[2]
        if hit_normal:
            self.normal = hit_normal
                
    def main(self):
        turn, move, jump = self.keyboard()
        self.rotation.z = turn * turn_speed
        if self.col_floor.positive:
            self.floor = self.col_floor.hitObject
            self.velocity.x = move * move_speed
            self.force.z = jump * jump_force
        self.get_normal()
        self.own.localLinearVelocity.xy = self.velocity.xy
        self.own.applyForce(self.force + self.gravity, True)
        self.own.alignAxisToVect(self.normal, 2, move_speed / 20)
        self.own.applyRotation(self.rotation, True)

def box(cont):
    own = cont.owner
    sensors = cont.sensors
    if 'translation' not in own:
        own['translation'] = Translation(own, sensors)
    own['translation'].main()
    
def mesh(cont):
    own = cont.owner
    velocity = own.parent.localLinearVelocity.x
    own.applyRotation([0, velocity * pi / 2 / tic_rate, 0], True)

Hi, I have found this script on the Unity forum (Magnetic ball - Questions & Answers - Unity Discussions and was wondering if it would work for what i am trying to achieve as i cant get the code to work :frowning: .

I get the following error

error CS0246: The type or namespace name `GameManager’ could not be found. Are you missing a using directive or an assembly reference?

Any ideas why?

Thanks

Nick