Hello!
I'm having some small issues with the code in one of my classes. I'm trying to create a custom Kismet node that, when triggered, will change the camera view (code from the UDN Camera Technical Guide). I have the following code:
CameraMovement.uc
// extend UIAction if this action should be UI Kismet Action instead of a Level Kismet Action
class CameraMovement extends SequenceAction;
//--------------------------------------------------------------------------------------------------------------------
// Player Pawn/Controller
//--------------------------------------------------------------------------------------------------------------------
var Actor ActorObj;
//--------------------------------------------------------------------------------------------------------------------
// Created Kismet Action Node
//--------------------------------------------------------------------------------------------------------------------
event Activated()
{
//top-down view
if(InputLinks[0].bHasImpulse)
{
changeCamera(1);
updateCameraName("Top-Down");
}
//third person view
else if(InputLinks[1].bHasImpulse)
{
changeCamera(2);
updateCameraName("Third Person");
}
//isometric view
else if(InputLinks[2].bHasImpulse)
{
changeCamera(3);
updateCameraName("Isometric");
}
//Side-Scrolling view
else if(InputLinks[3].bHasImpulse)
{
changeCamera(4);
updateCameraName("Side Scroller");
}
}
//--------------------------------------------------------------------------------------------------------------------
//Camera Mode Changer
//--------------------------------------------------------------------------------------------------------------------
function changeCamera(int camID);
{
//locally declare custom variable types to capture converted generic objects
local CameraPawn rPawn;
local CameraPlayerController rController;
//ensure valid player actor was supplied to this action node through variable links
if(ActorObj != none)
{
//first try and convert attached actor variable to controller
rController = PlayerController(ActorObj);
if(rController != none)
{
rPawn = CameraPawn(rController.pawn);
}
//if the actor failed to be converted to a controller or the controller's pawn = null, try to convert actor to
//custom pawn type
if(rPawn == none)
{
rPawn = CameraPawn(ActorObj);
}
//if the pawn has been successfully populated and converted, change its camera mode
if(rPawn != none)
{
//first-person
if(camID == 0)
rPawn.CameraMode(CAM_FirstPerson);
}
else if(camID == 1)
{
//third person
rPawn.CameraMode(CAM_ThirdPerson);
}
else if(camID == 2)
{
//top-down
rPawn.CameraMode(CAM_TopDown);
}
else if(camID == 3)
{
//side-scroller
rPawn.CameraMode(CAM_SideScroller);
}
else if(camID == 4)
{
//isometric
rPawn.CameraMode(CAM_Isometric);
}
//Error
else
{
'log("Bad Camera ID: " @camID);
}
}
}
defaultproperties
{
ObjName="CameraMovement"
ObjCategory="PT1_Week4 Actions"
//clear input links
InputLinks.empty
InputLinks(0) = (LinkDesc="Top-Down")
InputLinks(1) = (LinkDesc="Third Person")
InputLinks(2) = (LinkDesc="Isometric")
InputLinks(3) = (LinkDesc="Side-Scroller")
//empty variable links
VariableLinks.empty
VariableLinks(0) = (ExpectedType = class 'SeqVar_Object', LinkDesc = "Player", PropertyName = "ActorObj")
//Empty Output Links So They Contain Only What We Want
OutputLinks.empty;
OutputLinks(0) = (LinkDesc = "Out")
//populate class member variable with default values
ActorObj = none
//if true, call handler function on all targeted actors; it is set to false because our actor isn't registered
//to handle said action
bCallHandler = false
//if true, all output links will have impulse set to true
bAutoActivateOutputLinks = false
}
Here's where I'm getting errors:
Any help would be greatly appreciated. I'm not 100% sure where I'm messing up. The first error I'm not so sure about. When I created the function, I made sure to make the brackets right away. Did I miss one? I'm thinking that if that's figured out, the other errors will disappear. Thank you in advance for helping a disabled user. ^_^
Replies
If you look there (line 55), your that's where your function 'changeCamera' is.
You have a ';' (line 54) that needs to be taken out. Thats where your '{' line 55 problem is coming from.
When I have script errors, if it's not obvious where they are, or what's causing them, I slowly comment things out (functions, if's, else, variables etc. etc. using /* and */) save and compile, and see if that portion is what was causing that specifc error. (Sometimes starting with large chunks of script, and slowly uncommenting more, and more, until your left with only several lines left commented that could be causing the issue.)
Sometimes looking for errors can be like searching for a needle in a haystack. That way makes it much more manageable for me. (and you won't have to go to the forums over a misplaced semicolon :P )
Hope that helps
new code:
I have trouble typing (Cerebral Palsy) so this isn't easy.....
There are two immediate errors to fix, one on line 26 and one on line 64. Line 26 is complaining about you using a variable or function called updateCameraName because it doesn't exist. Line 64 is complaining about the fact that you are trying to assign the value of a variable of one type to a variable of another type which cannot be converted (i.e you can't say integer X = string Y because that makes no sense). I suspect there are other issues to resolve once those have been fixed.
should say
disclaimer: I have no unrealscript experience, only other languages. But I'd be willing to bet that 'log is not a valid method name.
I stand corrected. Never would've believed that would be valid, weird API design decision.
but that one's caught me up a bunch of times...and if I recall it could totally cause errors like the ones your seeing.
Oh, cool. Still, I'm saying it's a weird symbol of choice for that
'`´ because those all look the same