Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Simulating asteroid gravity
Simulating asteroid gravity
2003-07-13, 7:53 PM #1
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.

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.
2003-07-13, 9:59 PM #2
I believe using the flag's from the "Walk on Walls" mod might be what your looking for, the ones that attatch the player to any surface that isn't 90 degree's or something I cant remember. I think if ya experiment with that you could get something cooked up [http://forums.massassi.net/html/smile.gif]

------------------
2003-07-14, 2:35 AM #3
Seifer, people like you always happen to pop out of the woodwork when I least expect it. :]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2003-07-14, 7:03 AM #4
That's the thing... I have SetPhysicsFlags(player 0x10), which makes something align perpedicularly to a surface. It doesn't seem to be working, and even if it did, it only works when you land on it. I wouldn't align if I was coming from underneith the asteroid.

------------------
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.
2003-07-14, 7:31 AM #5
do you have SetPhysicsFlags in the touched section of the cog, or the entered (so when you get close it aligns?)

------------------
- Laserjolt

Editing Abilities/Skills:
(In order of skill from least to most)

DLL, SFT, BM, CMP, KEY, DAT, PAR, COG, 3DO, MAT, SPR, TPL, SND, PUP, AI#, WAV, UNI

Folder: LucasArts
Size: 3.29 GB (3,540,445,700 bytes)
Size On Disk: 2.08 GB (2,239,862,836 bytes)
Contains: 21,338 Files, 938 Folders
Folder: LucasArts
Size: 7.41 GB (7,957,329,759 bytes)
Size on Disk: 5.16 GB (5,544,473,484 bytes)
Contains: 28,807 Files, 1187 Folders
Last Updated: 3/29/05
2003-07-14, 7:39 AM #6
Er, you would know if you looked at the COG... I have no touched or entered, it sets the physics flags when you are close to it.

------------------
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.
2003-07-14, 8:29 AM #7
I added touched, entered, and exited, with Set and ClearPhysicsFlags(player 0x10), and that part works now, but you can still fall off the edge of the asteroid. It might work if it was a sphere, but it's not.

------------------
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.
2003-07-14, 9:07 AM #8
I don't know if this is doable, but er, well I thought I'd mention it [http://forums.massassi.net/html/smile.gif]

(I thought be easier to explain if I'd draw a nifty picture.)

[http://www.xs4all.nl/~ceekelen/asteroids.JPG]

(edit: Why won't those darn imagetags work?)

------------------
Call me Vedder.
Author of: A Pirate's Tale (Mots SP)
APT homepage
----
<phantom> You're always going to be aloser if you attempt to aspire to massassi standards.
<phantom> They're a bunch of socially inadequate <beep> whores who have little or no lives.


[This message has been edited by ZOOIkes (edited July 15, 2003).]
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-07-14, 10:39 AM #9
Multiplayer syncing becomes a problem there, but it's a cool idea.

I've kind of abandonded that in favor of:

1. Adding smaller, Force throwable asteroids, keeping the bigger ones as I had before.

2. Making the larger ones destructable and have them explode into throwable debris.

Problem: Throw debris is not colliding with the rest of the level, since it's made out of 3DOs. How can I fix this?

------------------
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.
2003-07-14, 6:08 PM #10
How does the player 'fall off' your asteriod. You mean he just detaches from one of its surfaces? And 0x10 isn't working because the player won't attach to surfaces on the bottom of the asteroid?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-14, 8:03 PM #11
You fall off, like you'd fall off a cliff. 0x10 is working now, but it doesn't let me walk around the asteroid, nor does it make me perpendicular on the bottom because I never touch it with my feet, so I never attach.

------------------
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.
2003-07-14, 9:19 PM #12
Can I test this out?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-15, 12:22 AM #13
I'm just going to throw this idea to you and see if you can do it.
Instead of changing the position of the asteroids like ZOOIkes said, change the player. When a player teleports to another object, it takes the lookvector angles and EVERYTHING and can even change the orientation. I suggest creating a ghost (when the asteroid is touched) at the players position that is perpendicular to the line between the asteroid and the player. Then teleport the player to the ghost and then you should be able to attach to any surface of the asteroid top or bottom. I'll put up a pic in a couple minutes of what I mean.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-15, 12:34 AM #14
Here's the picture, I don't feel that I've explained this good enough but I need sleep to think. If you don't understand something just ask and I'll explain.

[http://www.massassi.net/ec/images/11873.jpg]

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 15, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-15, 4:15 AM #15
How would I get it to be perpendicular in the first place though?

------------------
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.
2003-07-15, 4:16 AM #16
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
Can I test this out?</font>


If you mean the COG, yes, if you mean the level, give me your e-mail.


------------------
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.
2003-07-15, 10:08 AM #17
I'm not sure if this is possible in JK but here is some of the mots code. My (new) idea is to make the ghost look at the asteroid (not perpendicular) then use
Code:
vec0=GetThingUVec(ghost);
playerpos=GetThingPos(player);
telespot=CreateThingAtPos(ghosttemp, FindSectorAtPos(playerpos), playerpos, vec0);
TeleportThingToThing(player, telespot);

to find the perpendicular position and teleport the player. "FindSectorAtPos" is a mots only verb, but if there is only one sector with the asteroid then there should be no problem in JK.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-16, 8:05 AM #18
Emon, my email is danadf@earthlink.net

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!