x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Could I get some help with a small syntax problem?

So I'm not at all familiar with C++ or UE4 in general, so I imagine this really isn't difficult to fix, but I'm having a little trouble. I'm following this (https://wiki.unrealengine.com/Oculus_Rift_Separate_View) tutorial to try and achieve the 'true first person' view for the player. It's been fine up to the 'YourCharacter.h' tab. I'm not sure of the syntax for global variables, and when I just paste

 public:
     virtual FRotator GetViewRotation() const OVERRIDE;

in, I get the following errors when I try to compile and run:

errors

Any help is greatly appreciated! Thanks very much.

Product Version: Not Selected
Tags:
more ▼

asked May 29 '14 at 09:39 PM in C++ Programming

avatar image

Beechey
3 4 5

avatar image Beechey May 30 '14 at 12:29 AM

I've updated the OP in the hopes someone can assist me. Thanks to those who posted!

avatar image ambershee May 30 '14 at 12:33 AM

The error is exactly what it says on the tin: "GetViewRotation: Can't override a 'final' function"

GetViewRotation is declared as final, which means it cannot be overridden.

I couldn't help but notice that your output has the -rocket command switch in it, which I'm assuming you're also copying from the tutorial. Rocket as the internal codename for the public UE4 build long before it became public - I suspect the tutorial you are following is potentially very out of date...

avatar image Beechey Jun 02 '14 at 12:22 PM

Ah damn, that's a shame. Well, I'll focus on other stuff until something similar arises then. Thanks for the help!

avatar image Tim C ♦♦ STAFF May 30 '14 at 03:22 PM

Hi Beechey,

We prefer to keep a record of all questions on the AnswerHub, and any solutions that are provided, so that future users can easily find help if they run into an issue that someone else already struggled with. If you have multiple or additional questions, it is requested that you post a new question for each one. I will be reverting this post back to your original question. Please feel free to create a new post for your additional questions so we can track those separately.

Thanks, Tim

avatar image Beechey May 30 '14 at 04:53 PM

Ah, fair enough, Tim. Is there any way we can close this or do you prefer to leave threads open? The issue is sorted anyway - silly me not reading instructions. I know better next time!

avatar image Tim C ♦♦ STAFF May 30 '14 at 06:31 PM

Hi Beechey,

We will typically leave a post open unless the discussion goes way off topic, or someone resurrects a really old post by adding a new question to it. This way, if someone else has another solution to the same issue that they would like to add, or needs to ask for clarification about something, they can easily do so.

If one of the answers that is given to a question you post helps resolve the issue you are having, or points you in the right direction for resolving it, make sure to select that answer as correct and/or leave a comment under it indicating what additional steps you took to make that answer work for you.

Have a great day!

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

I am not sure how you created your class, but the structure of your header file is wrong. When you create a new class, the code in your header file should look something like this:

 // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
 
 #pragma once
 
 #include "GameFramework/Character.h"
 #include "MyOculusCharacter.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class TESTOCULUSSETUP_API AMyOculusCharacter : public ACharacter
 {
     GENERATED_UCLASS_BODY()
 
     
     
 };
 

You would then paste the lines from the tutorial in like this:

 // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
 
 #pragma once
 
 #include "GameFramework/Character.h"
 #include "MyOculusCharacter.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class TESTOCULUSSETUP_API AMyOculusCharacter : public ACharacter
 {
     GENERATED_UCLASS_BODY()
 
 public:
     virtual FRotator GetViewRotation() const OVERRIDE;
     
 };
 

As ambershee mentioned, C++ is very powerful, but it also assumes you have a very good idea of what you are doing. It is not very forgiving. If you are not familiar with C++, I would recommend starting with something simple and building on that. It doesn't take long to learn C++, but it will take years to master it.

Edit For clarification, some parts of this structure are unique to Unreal Engine 4. Creating a standard C++ class will not work for you in this case. However, if you create a class through the Editor by using File -> Add Code to Project, you will be presented with a class creation "wizard" that will provide you with a .h and .cpp file for a new class that already has the basic structure needed to create a new class in UE4.

more ▼

answered May 29 '14 at 11:09 PM

(comments are locked)
10|2000 characters needed characters left

You have no class definition (should be created for you automatically when you add code through the editor).

To me this indicates that you have no familiarity with C based languages at all - C++ is powerful, but will give you a lot of opportunity to really break things and cause yourself a lot of frustration whilst not getting anywhere. I would very strongly recommend at least picking up a book covering the basics and working through it if you intend to start programming and want to achieve anything.

I have a copy of the first edition of this book and it is quite reasonable: http://www.amazon.com/Beginning-C-Through-Game-Programming/dp/1435457420/ref=sr_1_1?ie=UTF8&qid=1401403762&sr=8-1&keywords=beginning+c%2B%2B+game+programming

more ▼

answered May 29 '14 at 10:50 PM

avatar image

ambershee
603 23 30 52

avatar image Beechey May 29 '14 at 11:15 PM

I'm familiar with C, nothing to this extent though. Kinda sucks that my university doesn't really cover anything that in-depth, just glazes over and teaches the theory behind it. I guess it couldn't hurt at all to pick it up and learn.

Thanks for the advise!

(comments are locked)
10|2000 characters needed characters left

You need to create a class like this:

 class ATrueFirstPerson : ACharacter
 {
 
 public:
       virtual FRotator GetViewRotation() const OVERRIDE;
 
 }
more ▼

answered May 29 '14 at 10:51 PM

avatar image

vibgyorc6
75 12 19 25

avatar image Shadowriver May 29 '14 at 11:00 PM
 UCLASS()
 class ATrueFirstPerson : ACharacter
 {
 
        GENERATED_UCLASS_BODY()
 
 public:
       virtual FRotator GetViewRotation() const OVERRIDE;
  
 }

....to be more exact, without UHT macros class won't be visible for the rest of the engine code.

Best way to make class is use "Add Code To Project" in editor, it will setup everything you need

avatar image vibgyorc6 May 29 '14 at 11:09 PM

oops, I completely forgot about the macros. :P

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question