Author Topic: Floating items?  (Read 1477 times)

Hey guys, I'm trying to create a teleporter system, where you can teleport between two points by walking into these meshes. I created an item and packaged the onCollision function. The only problem is that when I spawn the item, it floats ~2 feet above the ground. Any ideas? If I walk into it, sometimes it starts floating upwards.

The datablock:
datablock ItemData(TeleporterItem)
{
   category = "Weapon";
   className = "Weapon";
   
   shapeFile = "./models/teleporter.dts";
   mass = 3;
   density = 0.2;
   elasticity = 0.2;
   friction = 0.6;
   emap = true;
   
   doColorShift = true;
   colorShiftColor = "0 0.4 0.8 1";
   image = MetalImage;
   candrop = true;
   canPickup = false;
};


How I'm spawning it:
%teleporter = new Item()
{
   datablock = TeleporterItem;
   canPickup = false;
   position = %client.player.getHackPosition();
   client = %client;
};
%teleporter.allegiance = %client.slyrTeam.name;
%v = %client.player.getVelocity();
%teleporter.setVelocity(vectorAdd(%v,getRandom(-8,8) SPC getRandom(-8,8) SPC 10));
%client.chatMessage("\Teleporter placed!");

Try calling %teleporter.setScopeAlways(); after setting the velocity.

Nope.



It spits out correctly, but it stops as if the ground plane is higher than it actually is.
Could it be because of the model? It's centered and everything in blender, so IDK. A similarly-made bomb is acting the same way.
« Last Edit: September 06, 2015, 10:53:31 PM by Johnny Blockhead »

Since this has been on the front of the board for a very long time with no posts, heres some more updated code:
%client.ultCD = $Sim::Time + 15;
%teleporter = new Item()
{
   datablock = TeleporterItem;
   canPickup = false;
   position = %client.player.getHackPosition();
   client = %client;
};
%teleporter.allegiance = %client.slyrTeam.name;
%v = %client.player.getVelocity();
%teleporter.setVelocity(vectorAdd(%v,getRandom(-8,8) SPC getRandom(-8,8) SPC 10));
%teleporter.setScopeAlways();
%client.chatMessage("\c5Teleporter placed!");
%client.hasJustTeleported = 1;
%client.schedule(2000, teleporterCooldown);
if(%client.teleporter1 $= "")
   %client.teleporter1 = %teleporter;
else if(%client.teleporter2 $= "")
   %client.teleporter2 = %teleporter;


To clarify, still not fixed.
« Last Edit: September 12, 2015, 06:25:34 PM by Johnny Blockhead »

%teleporter.static = true;

No go. All that does is make it float in space (which it normally does), but at the position of when it's first spawned. If I make it static after it gets ejected up and 'lands', it stops floating upwards if I stand colliding with it.

Edit: looks like when it floats upwards it goes to the top of my collision box
Edit 2: Temporary fix is to spawn it at getPosition + "0 0 0.1" and disable the velocity. It sits on the ground like a good little teleporter. Granted, this isn't because of actual gravity, just because it was spawned initally into the ground. I need an actual fix though, since considering this is a teleporter, it would be bad if it started spawning people mid-air [accomplished by jumping up and spawning one]. Where's gravity when you need it?

I can't seem to collide with the teleporters if they're spawned that way. If I spawn them with velocity, on getPos, they go up but stop at the same level every other one does. Then, they just stay there.
« Last Edit: September 13, 2015, 08:45:07 PM by Johnny Blockhead »

try placing the setScopeAlways() before you set the velocity

edit: actually i just fixed the issue myself accidentally
once you spawn the item do %item.setTransform(%position); and it'll behave normally
this is a summarized version of what i have:
« Last Edit: September 14, 2015, 06:18:35 PM by Gytyyhgfffff »