Home Unreal Engine

Missing a bracket somewhere?

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:

th_camera_errors.png

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

  • dissonance
    Options
    Offline / Send Message
    What are you using to edit? If you genuinely are just missing a bracket, something with syntax highlighting like Notepad++ or Geany will clear that up in no time.
  • Neavah
    Options
    Offline / Send Message
    your error tells you it's from line 55 (the first error).
    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 :)
  • Raptor-chan
    Options
    Offline / Send Message
    I tried getting rid of the semicolon and now I get even more errors? Help? I'm a bit confused. :(

    th_camera_errors2.png

    new code:
    // 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
    	
    }
    

    I have trouble typing (Cerebral Palsy) so this isn't easy.....
  • ambershee
    Options
    Offline / Send Message
    ambershee polycounter lvl 17
    Cerebral Palsy may make it difficult to type, and I sympathise, but it's not an excuse for not learning to debug your own code. What's more, is that this looks an awful lot like a college assignment, so you really should be asking your tutor if you need help getting to grips with debugging rather than relying on forums to pick out your errors for you.

    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.
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    I'm guessing the part where it says
    'log("Bad Camera ID: " @camID);
    

    should say
    log("Bad Camera ID: " @camID);
    

    disclaimer: I have no unrealscript experience, only other languages. But I'd be willing to bet that 'log is not a valid method name.
  • Froyok
    Options
    Offline / Send Message
    Froyok greentooth
    `Log is the shortcut for LogInternal, in unrealscript it's valid.
  • dissonance
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    Froyok wrote: »
    `Log is the shortcut for LogInternal, in unrealscript it's valid.

    I stand corrected. Never would've believed that would be valid, weird API design decision.
  • ambershee
    Options
    Offline / Send Message
    ambershee polycounter lvl 17
    It's not weird; '`' is the preprocessor macro. You can define other macros if you wanted to.
  • blankslatejoe
    Options
    Offline / Send Message
    blankslatejoe polycounter lvl 19
    though, dissonance has a good point, it's NOT a single quote, it should be that little tick that "SHIFT + ~(tilde)" makes. Some word processors like to change it to a single quote with their auto-formating. Course, web forums like this one may do some auto-formating that too, so it might be fine if you check back in your actual code.

    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.
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    ambershee wrote: »
    It's not weird; '`' is the preprocessor macro. You can define other macros if you wanted to.

    Oh, cool. Still, I'm saying it's a weird symbol of choice for that :D

    '`´ because those all look the same D:
  • ambershee
    Options
    Offline / Send Message
    ambershee polycounter lvl 17
    Yeah, it's a genuinely shit choice. Most international keyboards don't even have that symbol.
Sign In or Register to comment.