Game Development Community

Tiles speeds

by Bruno · in Torque Game Builder · 11/17/2005 (3:23 pm) · 5 replies

Hi.,

I'm tryng to do the following..,
I have a layer, moving at a speed of -12 in the X axis.
Then i have a object, that shows up in a predefined location of the layer, and i have it with a linear speed of -12 in the X axis so that he scrolls at the same speed as the layer, so he appears to be immobile.
The problem is, -12 for the sprite is not the same speed as -12 for the axis, but, that's not the only problem.
I was able to find a somehow ok speed, if the sprite is at -18 he appears to be static, however, when he shows up in the screen he seems to be moving at high speed, then stops and moves at the same speed as the layer, and when almost at the end of the screen, it starts accelerating again but backwards...
I simply set his speed with, setLinearVelocityX(-18); .., am i doing something wrong ?
thanks,

Bruno

#1
11/20/2005 (5:52 pm)
Anyone ?
#2
11/20/2005 (7:16 pm)
You might want to post some code snippets - sometimes people find that easier to give you comments on. My first guess is that you may have some sort of gravity, friction, or something else set for the sprite? Possibly a setWorldLimit on it that causes it to change speed when it hits the edge of the screen?
#3
11/21/2005 (4:45 am)
Thanks Steve..,
No i don't have any gravity or friction enabled.
I don't quite understand why the setWorldLimit would made it increase of slow down it's velocity speed, but i commented the setWorldLimit, and the problem is still there..
Here it is how i setup the sprite :

function spawn_platform1()
{
 

	%enemy = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
	%enemy.setSize( "50 50");
	%enemy.setPosition("60 20");
	%enemy.setImageMap( platform1_ImageMap );

	%enemy.setLinearVelocityX(-20);
	%enemy.speedX = -20;

	//%enemy.setWorldLimit( kill, "-180 -60 180 40" );

	 
	// Set enemy collision info

	%enemy.setGroup( 2 );
	%enemy.setLayer( 2 );
	%enemy.setCollisionActive( true, true );
	%enemy.setCollisionMaterial( standardMaterial );
	%enemy.setCollisionPolyCustom( 5, "-0.9 0 0 -0.6 1 -0.3 1 0.3 0 0.5" );
	%enemy.setCollisionMasks ( BIT(1), BIT(1) );
	%enemy.setCollisionCallback( true );
	%enemy.shields = 6;
	%enemy.ShipType = 19;

	// Set up collision info
	%enemy.tag="enemy_plat";
}
#4
11/21/2005 (6:35 am)
Standard Material has friction applied.
If you need one without friction you need to create an own material.
#5
11/22/2005 (7:59 am)
Thanks Marc, that was the problem :)