Converting to C++ from UnrealScript

Hi all,

I’ve a few mods here and there in UDK with the script for side-scrolling cameras, or weapons etc, is there a way to bring my old code into UE4, or does it need to be completely re-written?

Im more designer/artist than code so if this is the case, it will write UE4 off for me as my core engine…

Cheers in advance

Dodge

gonna have to rewrite it as unrealscript was completely removed, its full C++ now

No, there no Unreal Script so you will need to re-write, but if you artist you might find Blueprint frendly for you. Here example of a guy with same issue like you have,who making game right now:

https://youtube

You shouldn’t need to reinvent too many wheels, depending on what your code was doing. The general idea to keep in mind, UnrealScript has similar syntax to C++ already, and by and large, your algorithms should be able to be ported over to C++ with virtually no difficulty, and should continue to work.

The only things that are absolutely not able to be ported are States, replication blocks and your default properties block. States do not exist any longer, replication is handled in a very similar fashion, but not exactly the same, and your default properties block is now your C++ constructor, as it should have been the whole time.

It is quite unfortunate that you feel this is too much of an undertaking, as I think that working in C++ has been a pretty healthy release from the UnrealScript world. I am playing with the idea of writing an UnrealScript binding that would allow you to move your UDK based UnrealScript to work in UE4 land. If you are interested in it, I would love to have a chat and maybe sort out the details.

There is also the option of not porting the code if it seems like its going to be too daunting a task, you could finish up what you were doing on UDK and start a smaller learning project on UE4 if youre not entirely confident :cool:

I would rather ask here instead of starting a new thread. Looks like I’m a total noob once again lol. Since states are gone, what do we do now to go about making such behavior?

You can recreate a similar type of functionality, but nothing quite as easy to parse at a glance in C++. One road is to have a switch that executes sub methods for each state, and default for when that state should skip an event.

You can also play with composition, where you compose a given object with a reference to an instance of a method that is friendly and executes something, similar to components. The trick here is that you need to swap instances in and out as your states need to be transitioned.

There are other opportunities for you as well, like making extremely obfuscated Macros that allow you to do one or both of the above. There is, however, no simpler solution in C++, at least not yet =) Maybe I will go ahead and write it if you all send me a check.

[BTW]
This is absolutely not a NOOB question. You did good, keep it up. Questions like this are the inspiration to many.
[/BTW]

Behavior Trees are built in. That is probably the easiest built in way to do AI in UE4.

Well UnrealScript has similar syntax to C++ and i seen UE APIs are made so it’s very easy to transition, you could five it a shot :slight_smile:

But I don’t use states just for AI, I made a fresh UDK install about 5 days ago and have a pawn that uses states for all of its different movement behavior (I was experimenting with wall-running and the like). Looks like its back to if statements. :stuck_out_tongue:

With that mindset you would also be able to argue that transitioning between Java and C is an easy transition. I know of no one who would agree with that. Unrealscript has its oddities and will require a non trivial amount of time to move over. The syntax constructs, and organization of code is similar, but there are some patterns that you fall into found in the language that may need to be unlearned, like accessed Nones.

What mean by “easy to transition” is fact that in API i can see exact same patterns which might be helpful with transitioning once you learn C++ basis which i know it’s wall which once you cross it things become easier.

I don’t it simply my felling :stuck_out_tongue:

Okay, I’ve made a project and I have a few simple scripts that successfully compile. Let me check my understanding. I will be using my class constructors as I used to use default properties and postbeginplay?

Constructors do replace defaultproperties, but not BeginPlay. You override that function in C++ just like you did in UnrealScript.

wow!!
its really wonderful

As JamesG said, you override virtual functions now to extend base classes. You should be happy to find out that most of the methods you have used previously in UnrealScript are likely to be available, in one incarnation or another, in UE4s Source. There are absolutely methods that have been deprecated (like using placeable as a UClass directive for instance) that will only be addressed with experience with the new platform.

And of course you have the giants around you to stand on top of.

Well gents, cheers for all the answers! (Unfortunately didn’t get any notifications someone had replied!)

My original understand of UnrealScript wasn’t brilliant, but I could just about write some custom stuff and also copy/pasta sections to make something work,

It’s brilliant that C++ is now integrated as it gives the programmers more room to play (I guess?) which can only lead to new advancements,

With this is mind, I may just stick with the basics (i.e FPS shooter/puzzle) - Use UDK more for my art/design portfolio, and switch over to Unity for learning Javascript etc,

You can wrap such functionality into struct and the use ticker to switch between “states”. For example in your struct you have IsMoving, in ticker you add if(IsMoving) DoSomething. You of course need to manage setting up bools.

Sorry for obfuscated example but I’ writing it from my tablet. I will give you my more detailed solution once I’m in home.

@up I don’t know why would you switch to unity if you can use blueprints inside UE4?