Proud moments
by Kevin James · in Torque Game Builder · 11/30/2008 (4:09 pm) · 4 replies
I share this for your benefit, not for mine. We all do some very, very dumb things when it comes to programming; I thought it would be beneficial if I started a support group so that everyone feels like they aren't as stupid as that guy. Meaning me of course.
Here is a splendid function that I was working on:
So that when the player is facing right, the camera will be bias toward the right and when the player is facing left . . . yeah. Little did I know that this would confound me for about half an hour. My thoughts:
WHY IS THE FREAKING CAMERA STAYING IN THE SAAAAMMEE PLACE!!!!!111!!!121111uno uno.
Of course I was angry because it was obviously TGB's fault for being stupid, little did I consider that I was in fact the stupid one.
The fixed code:
Here is a splendid function that I was working on:
if([b]!%this.flipX[/b])
{
if(%this.cameraMount !$= "CR")
{
warn("CR here");
%this.cameraMount = "CR";
playerCameraMount.dismount();
playerCameraMount.mount(%this, [b]"5 0"[/b], 2, false, false, false, false);
}
}
else if([b]%this.flipX[/b])
{
if(%this.cameraMount !$= "CL")
{
warn("CL here");
%this.cameraMount = "CL";
playerCameraMount.dismount();
playerCameraMount.mount(%this, [b]"-5 0"[/b], 2, false, false, false, false);
}
}So that when the player is facing right, the camera will be bias toward the right and when the player is facing left . . . yeah. Little did I know that this would confound me for about half an hour. My thoughts:
WHY IS THE FREAKING CAMERA STAYING IN THE SAAAAMMEE PLACE!!!!!111!!!121111uno uno.
Of course I was angry because it was obviously TGB's fault for being stupid, little did I consider that I was in fact the stupid one.
The fixed code:
playerCameraMount.mount(%this, [b]"5 0"[/b], 2, false, false, false, false);
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
That is actually very similar to what I ended up doing, but it was jerky and made me feel queasy, haha. I went with just a static mount to the player to avoid queasiness and unwanted bugs.
Thanks,
Kevin
ps
Didn't know that about dismounting and mounting. Good to know.
11/30/2008 (8:33 pm)
Hey, thank-you Conor!That is actually very similar to what I ended up doing, but it was jerky and made me feel queasy, haha. I went with just a static mount to the player to avoid queasiness and unwanted bugs.
Thanks,
Kevin
ps
Didn't know that about dismounting and mounting. Good to know.
#3
11/30/2008 (9:47 pm)
Hmm, I was also unaware of that. I'll look into it and let Melv know too (if it really is creating duplicate link points).
#4
With that said, mount-points (link-points) are reused and reference counted so if two things ask for the same position, they'll get the same link-point. Likewise when both dismount (and only when both have), the link-point will be destroyed.
You should be careful though that the position is identical. Being as the type here is float, even a relatively small change is counted as a different point.
What Conor said is definately good advice though.
Melv.
12/05/2008 (4:56 am)
I would agree that mounting and dismounting should be done with caution as they are not the quickest operation in the world to setup and destroy.With that said, mount-points (link-points) are reused and reference counted so if two things ask for the same position, they'll get the same link-point. Likewise when both dismount (and only when both have), the link-point will be destroyed.
You should be careful though that the position is identical. Being as the type here is float, even a relatively small change is counted as a different point.
What Conor said is definately good advice though.
Melv.
Conor O'Kane
cokane.com
In code:
function playerCameraMountClass::onUpdate(%this){ %this.setPositionY($player.getPositionY()); if ($player.getFlipX()) %this.setPositionX($player.getPositionX() -10); else %this.setPositionX($player.getPositionX() +10); }