<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Adding gravity to a planet]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=508&amp;type=atom"/>
	<updated>2012-12-31T01:08:58Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=508</id>
		<entry>
			<title type="html"><![CDATA[Re: Adding gravity to a planet]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3135#p3135"/>
			<content type="html"><![CDATA[<p>Thanks. <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2012-12-31T01:08:58Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3135#p3135</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adding gravity to a planet]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3127#p3127"/>
			<content type="html"><![CDATA[<p>I think it&#039;s the reverse, and not local :</p><div class="codebox"><pre><code>force = {corepos[1] - playerpos[1], corepos[2] - playerpos[2], corepos[3] - playerpos[3]}


addCentralForce(player, force)</code></pre></div><p>you also might need to normalize the force vector :</p><div class="codebox"><pre><code>function getLength3d(vec)

    return math.sqrt(vec[1]*vec[1] + vec[2]*vec[2] + vec[3]*vec[3])

end

function normalize3d(vec)

    length = getLength3d(vec)
    vec[1] = vec[1] / length
    vec[2] = vec[2] / length
    vec[3] = vec[3] / length
    return vec

end</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-12-30T10:30:49Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3127#p3127</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adding gravity to a planet]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3124#p3124"/>
			<content type="html"><![CDATA[<p>playerpos = getPosition(player)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; corepos = getPosition(core)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp;&nbsp; &nbsp;gravity = {0, 0, 0}<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; addCentralForce(player, {playerpos[1] - corepos[1], playerpos[2] - corepos[2], playerpos[3] - corepos[3]}, &quot;local&quot;)<br />&nbsp; &nbsp; </p><p>Like this?</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2012-12-30T00:00:27Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3124#p3124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adding gravity to a planet]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3123#p3123"/>
			<content type="html"><![CDATA[<p>set the gravity to zero, set the objects physics and use &quot;addCentralForce&quot; :<br /><a href="http://wiki.maratis3d.org/index.php?title=AddCentralForce">http://wiki.maratis3d.org/index.php?tit &#133; ntralForce</a></p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-12-29T23:29:31Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3123#p3123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Adding gravity to a planet]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3122#p3122"/>
			<content type="html"><![CDATA[<p>Hey! Now I&#039;m doing a script for planetary gravity.</p><p>&nbsp; &nbsp; core = getObject(core)<br />&nbsp; &nbsp; planet = getObject(planet)<br />&nbsp; &nbsp; player = getObject(player)</p><br /><br /><p>&nbsp; &nbsp; playerpos = getPosition(player)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; corepos = getPosition(core)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; gravity = {playerpos[1] - corepos[1], playerpos[2] - corepos[2], playerpos[3] - corepos[3]}</p><p>Thinking that the player will be drawn to the core of the planet by subtracting there co-ordinates all the time, and that the physics-enabled-planet will provide ground to collide with.</p><p>This is my idea, but it doesn&#039;t work.</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2012-12-29T23:05:59Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3122#p3122</id>
		</entry>
</feed>
