Synchronizing objects on an axis:
objtarget:SetAbsOrigin(Vector((objtarget:GetAbsOrigin()).x,(objtarget:GetAbsOrigin()).y,(objinfo:GetAbsOrigin()).z))
But it isn't working. I'm not sure about getting the components from the vector, and if AbsOrigin is what I want. If I can get this working I can probably get the geomatry go work on any axis, but I don't want to do that since it will make the code more complicated until I have the base code working. Any Advice?
Thank You,
Sound Logic
Try setting variables for the x, y, z coordinates and printing to make sure you are getting the x, y and z values correctly.
P.S. I know nothing of squirrel, just rudimentary and general scripting knowledge.
Also, you can't treat an entity's name as a class/object.
The following is untested and I just wrote this in the post editor but it might work:
function ChangeY(target, source) {
objectone = Entities.GetEntityByName(null,target);
objecttwo = Entities.GetEntityByName(null,source);
oone_origin = objectone.GetOrigin();
otwo_origin = objecttwo.GetOrigin();
objectone.SetOrigin(Vector(oone_origin.x, otwo_origin.y, oone_origin.z));
}
(it had some sloppy mistakes see below for fixed version)
RunScriptCode:OverrideZ(Obj1,Obj2)?
Is this right?
Because it doesn't seem to be working, and I'm not sure if it is the script or my implementation of it.
Thank You,
Sound Logic
Thank You,
Sound Logic
EDIT:
I looked into some of the code examples, and think I might have fixed some problems:
function OverrideZ(target, source) {
objectone <- Entities.FindByName(null,target);
objecttwo <- Entities.FindByName(null,source);
oone_origin <- objectone:GetOrigin();
otwo_origin <- objecttwo:GetOrigin();
objectone.SetOrigin(Vector(oone_origin.X, oone_origin.Y, otwo_origin.Z));
}
Not quite sure though
Thanks Omnicoder!
My original code was sloppy and untested so I made sure it works this time:
function ChangeZ() {
local objectone = Entities.FindByName(null,"obj2");
local objecttwo = Entities.FindByName(null,"obj1");
local oone_origin = objectone.GetOrigin();
local otwo_origin = objecttwo.GetOrigin();
objectone.SetOrigin(Vector(oone_origin.x, oone_origin.y, otwo_origin.z));
objectone.SetVelocity( Vector( Max(objectone.GetVelocity().x-1, 0), Max(objectone.GetVelocity().y-1, 0), objectone.GetVelocity().z) );
}
function Max(a,b) {
return (a == b) ? a : ((a > b) ? a : b);
}
It should be set as a script think function and you'll need to change the obj1 and obj2 strings if you want it to affect different objects.

It gets into odd spins sometimes, you can force set its angles or be stricter about its velocity if its a problem.
And btw <- is only for globals use = for locals in functions.
Thank You So Much,
Sound Logic
Thank You,
Sound Logic