Space Noxx II has some nice asteroids in it, which are accessable by the player. Using the following COG, I've simulated gravity on the asteroids by adding velocity to the player, towards the center of the asteroid, if the player is within a distance of the thing, that distance is the movesize of said thing. The gravity and force stuff works fine, but I want to be able to walk all the way around the asteroid, I want the player's feet to be touching the asteroid. Any idea how I might do this?
Help is very much appreciated.
------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Help is very much appreciated.
Code:
# Jedi Knight COG Script # # AsterAttach.COG # # Created by Emon. E-Mail: emon1337@yahoo.com - ICQ: 35960628 # Feel free to use this COG as long as credit is given in the readme file. # # "Attaches" players to the asteroids when they land on them by # setting thingflags so they align with it and removing their gravity, # producing the effect that they are held onto the asteroid by it's # gravitational pull. Effects are removed upon leaving the asteroid. # # Addm: Okay, so it didn't actually attach the player, but it makes it # harder to stay on because the asteroid may roll you off over time # from its rotating. It also looks cool and is disorienting. # # This COG is not supported by LucasArts Entertainment Co. #==============================================================# flags=0x240 symbols thing Asteroid0 thing Asteroid1 thing Asteroid2 thing Asteroid3 thing Asteroid4 thing Asteroid5 thing Asteroid6 thing Asteroid7 thing Asteroid8 thing Asteroid9 thing Asteroid10 thing Asteroid11 thing Asteroid12 thing Asteroid13 thing Asteroid14 thing Asteroid15 thing Asteroid16 thing Asteroid17 thing Asteroid18 thing Asteroid19 thing Asteroid20 thing Asteroid21 thing Asteroid22 thing Asteroid23 thing Asteroid24 thing Asteroid25 thing Asteroid26 thing Asteroid27 thing Asteroid28 thing Asteroid29 thing Asteroid30 thing Asteroid31 thing Asteroid32 thing player local int I=0 local message startup message killed message newplayer message pulse end #==============================================================# code #------------------------------------------------------ startup: Sleep(2); player = GetLocalPlayerThing(); SetPhysicsFlags(player, 0x1); ClearPhysicsFlags(player, 0x10); SetPulse(0.1); Return; #------------------------------------------------------ killed: SetPhysicsFlags(player, 0x1); ClearPhysicsFlags(player, 0x10); Return; #------------------------------------------------------ newplayer: SetPhysicsFlags(player, 0x1); ClearPhysicsFlags(player, 0x10); Return; #------------------------------------------------------ pulse: for(I = 0; I <= 32; I = I + 1) { if(Asteroid0 != -1) { // Only proceed if the player is close enough to the asteroid. Bigger asteroids have a bigger movesize, // which results in you getting pulled towards a bigger asteroid sooner. if(VectorDist(GetThingPos(player), GetThingPos(Asteroid0)) < GetThingMoveSize(Asteroid0)) { // An attempt to align the player to the asteroid perpendicuarly, but it failed. // Instead, it makes the front of the player's body face the asteroid, not his feet. // Use of VectorCross didn't work, but was, er, interesting. SetThingLook(player, VectorSub(GetThingPos(Asteroid0), GetThingPos(player))); Print("If you can read this, you are too close!"); ClearPhysicsFlags(player, 0x1); SetPhysicsFlags(player, 0x10); AddThingVel(player, VectorScale(VectorSub(GetThingPos(Asteroid0), GetThingPos(player)), 0.5)); } else { SetPhysicsFlags(player, 0x1); ClearPhysicsFlags(player, 0x10); } } } Return; #------------------------------------------------------ end
------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.