Download

Think chess, but that's not what I'm doing

So… I’d like to see a tutorial (primarily because the kit is so large that it’s hard to know where to bite) that does something like chess or checkers with pawns as the C++ objects — or at least I think I want pawns.

Specifically, I’d like to know how, in Unreal, to select a Pawn and drag it to a new location … just in 2D for now.

Objects that can be positioned are Actors.

A Pawn is specifically something which is not only manipulated, but receives keyboard/mouse input from a player, and “inhabits” the player in a way.

Thus, just clicking-and-moving an object can be done entirely with Actors. Mark them “replicates,” and when the user lets them go, run an Event that runs on the server to actually move the piece (and check rules) and replicate the new position, using a reliable broadcast. You might want to turn off “replicate position” for the actor, because you want people to be able to pick up the pieces without fighting the server replication stream.

If the objects are going to move around / walk / animate, then you might benefit from making them a Character, even though the PlayerController won’t necessary Possess them. The PlayerController could tell a separate AIController on the pawn where to go, for example. Or you could just use a Skinned Mesh component on a regular actor, and an Animation Blueprint, and go from there.

Ok… So what is the relationship here? Actor < Pawn? Can you give me a breakdown of the relationship or power level? I assume, from what I’ve seen so far that they don’t subclass each other — that they’re different…

Oh-and… another question from what I was watching today… The video was creating an interface class — and providing an interface with 3 functions defined… pure virtual style — that is with no implementation — but not ‘virtual’ … then in a subclass realizing this “interface” … something that subclassed both Actor and this new interface (I think it was actor) … the demonstration created non-virtual classes … I think calling then really-virtual classes. Is there a problem with defining virtual functions in a subclass of Interface?

The class hierarchy goes Object → Actor → Everything else that can be placed in the world

OK. Is there a tutorial concerning an interface where I want the user to be able to click and drag an Actor, then? Think chess game, for the sake of argument.

Look at the top down template for starting point.

It’ll get you how to do the click trace mouse position and how to tell AIs to reach that spot.

Having the location means you can move anything movable to it…

Yes… but is there a tutorial to follow?

Like anything else C++ / C or coding

No.

You bash your head at it and break working things apart until you learn it.

OK. Let’s start with a direct question, then. The “top-down” template just gives me a little man I can run around in the box. Cool, but not-at-all what I’m looking for.

Where do I look for how to compose an interface where … imagine the chess pieces on the board now — where I can click on a chess piece to focus on it — and then move it. Obviously, afterward, I’d want to click on another piece and deal with it, etc. Eventually, I’d want several people to join multiplayer and be able to click on the pieces and interact with them. Are there any resources to help me here — alternatively, what functions/classes should I look at to compose the interface?

First, create the starter project as a C++ project, not just Blueprint. You can also follow the C++ quick start in the documentation:

Second, read each of the C++ classes that it makes for you when you do this.

Third, read up on the gameplay classes in the documentation. The hierarchy is “UClass → AActor → APawn → ACharacter” but also “UClass → AActor → APlayerController”

Fourth, read up on the Unreal reflection / Unreal Header Tool system – it is CRUCIAL that you understand this, because it will use macros and code generation to generate a flavor of C++ that is not the flavor they’d teach you in school. The benefit of this flavor is that editor integration, replication, savegame, and garbage collection, becomes mostly-solved problems.

Fifth, use the Google for your own education. Search for the things or questions you have, and take a look at the top five hits or whatever to see whether they describe something you don’t yet know, that seems relevant to the question. There’s actually a lot of documentation on the Unreal documentation site, but it’s often a bit hard to get into, and it sometimes doesn’t go as deep as you want. At that point, you can ask specific questions in forums or AnswerHub, or you can read the engine code (or, likely, do both!)

OK mister RTFM. Thank-you (sarcasm). Heh. since school was 1990-1994, they didn’t really teach C++. I was interested in it, of course, and I’ve kept up with it overtime. Most of my C stuff has been kernel related, so I’m not lost in macro land. I also worked for an outfit that released in C and C++ on 18 archetectures as diverse as DOS/Win3.1/10 flavors of unix/WinNT/VMS VAX and OpenVMS Alpha. So I’ve been down macro craziness before.

IMHO, C++ is getting to the point where much less macro-craziness is required (did you ever write early (as in 1992 or 1993) GL? Oi). I do notice that some of the generated code is using templates and dynamic casts … so … progress.

With all your advice, you managed to avoid answering my specific question. When I follow your steps one, two and three, I’m not clear on where the camera I control comes into this — and how selecting an object in the environment might work.

So… where do I look for that tidbit — It’s a difficult thing to search for because I’m not clear on the terminology to search for.

I think the problem is you are very unfamiliar with the engine.

It’s not C++, it’s basically its own language.

Start with blueprint. It’ll take you 3 months or so to get your head around how the basics actually work.

Once you do, applying that to c++ becomes somewhat trivial.

To answer your camera question.

The camera is handled by the Camara Manger. Which is instantiated by the player controller.
It’s a total mess that you really shouldn’t bother with al all.

The top down gives you “how” to detect clicking.
That’s basically all you need to make a checkers game.
You just move or slide actors around the board based on locations.

I am very unfamiliar with the engine. Most of that problem is not knowing where to look.

Well… no… to be fair to both UE and myself, it’s C++ integrated with an application.

… so in the case of the blueprint glue, it’s rather the same as the glue that binds a new dynamic kernel module to the kernel or a new python module to python. Internally, your generating symbols that are collected into a list either by the linker or by simply macros (hint: the linker is a much more elegant and C++'y way to achieve this magic).

I do actually have a good concept of how the magic machenery works, but that’s not the issue — knowing how the man behind the curtain does his job doesn’t make giving him instructions any more trivial.

I actually had also gathered this. I tried deleting the player controller and/or the network player spawn to see what default behaviour remained — it would appear the ability to swim around as a camera remains — without the ability to interact. Sigh.

Well… no again. So “puzzle” shows detecting clicking. Top down shows a follow where I clicked behaviour. Puzzle doesn’t seem to allow for camera adjustment, but it seems close. In-the-end, It seems starting with an empty project would be the most appropriate… and the new bits of tutorial have solved my DLL / linkage craziness.

Right now, I would “like” the camera behavior to be simple … maybe move with wasd, maybe turn with qe and set height with scroll wheel. pointing down at a settable (by me) angle for now. Then I’d like the mouse to provide a pointer and I’m assuming that UE can guess which Actor I’m clicking on. click to select, drag to move and context menu on right click — that would be my wishlist.

… but steps to convince the interface to behave — or a concrete example — would be a good step one.

Are there any examples along these lines? Is there anyone who could summarize the incantation to arrange my basic interface?

None of that nonsense. It’s just that you’ll learnt he function calls to use and you can them find them in code since they provide direct access via their own implementations.

No. And it’s not rocket surgery. You build a UI, you implement it. That’s it.
Same for camera movement.
You build a pawn, you make the game possess the pawn, you build the movement system for the pawn.

As I said maybe 10 times.

all you need is world locations and knowledge of how to move stuff in 3d space possibly over time.

You can pick those up quick following almost any starter tutorial for blueprint.

Almost all the logic and approaches for something so basic remains the same.
/ and when you ask for help in the BP section, maybe people can give you more direct answers since the questions probably won’t be as abstract as they are here.

OP is asking questions that are answered a million times over in many tutorials, in the docs, in examples projects…

This is a case of LOM (lack of motivation.)

You won’t understand a single bit of it since you aren’t familiar with the basics of unreal, but once you are further along you can find a functioning demo of multiplayer chess from a youtube channel called “Reids Channel.” You could use that as a reference.

I might have pointed to the manual, but, like, did you actually read it after that? Because they answer the questions that were asked in the thread.

Can you give me a breakdown of the relationship or power level? I assume, from what I’ve seen so far that they don’t subclass each other

Answered by the “game object architecture” link.

and providing an interface with 3 functions defined… pure virtual style — that is with no implementation — but not ‘virtual’

Answered by the Unreal reflection system link.

To select objects, try “Line Trace by Profile” (for a line trace in world coordinates,) or just bind the “on click” or “on touch” events on the collision components on the objects you want to select, and set the UI mode to a mode that shows the cursor.
If you need help also turning a cursor position on the screen into a line, check out “Convert Mouse Location to World Space” (and note that it gives you the “near camera plane” location, and then a direction to trace in to trace into the screen.

I really have gone through a half dozen or so tutorials looking for knowledge. I did also ask — if you think a tutorial explains this, point me at it. I actually don’t need much pointing, but slightly more than “read everything” or “doctor google…” would be nice.

In some cases, not knowing the terms unreal uses for things means I can’t search for how to get a mouse pointer into the default project.

yes. I read through the links you posted. I marked a few things that I needed to know.

OK… I got you here — this isn’t about “how do you get the interface to let you select something” something I also asked. This part that you quoted is a question about the structure of C++ that UE allows. I was noting that an example established modified object (Actor, I think, in this instance … or maybe it was Interface…) with new class functions.

Curiously the tutorial treated the subclassed class as “pure virtual” … well… that’s the best way to describe it — none of the new functions were virtual, but neither were they implemented. OK, I suppose if you never instantiate it and you override all those functions.

Then the tutorial established non-virtual override functions in a new subclass, that then also had virtual functions — and, AFAICT, the non-virtual ones calling the similarly named virtual ones.

Now… this is curious programmer behaviour unless a) they just don’t understand virtual functions or b) UE doesn’t allow them there — so it was all a workaround to have virtual functions … but not in a direct sub-class of the UE parent object. I was asking if this was a) or b).

But anyways… you avoided answering my direct (fairly complex) question by referencing an answer to an earlier question that your manual reference may have covered. Congrats (sarcasm).

Now… this does give me some pointers. Actually I assumed such location functions existed, but I’m kinda lost on how to get hold of the mouse pointer in the first place. The empty C++ project seems to leave me in flying mode. Need to turn that off. As above, I’d like some other camera controls, but how to get the mouse pointer on the screen during the running game — that’s my current pain point.

Thanks for the breakdown on the clicky once I get there — truly that does help

Do I really need to quote myself or can you go back a few posts and re-read them? Lol

The template literally does everything you ask for in terms of setting up stuff for cursor interaction.

And here you are asking about cursor interaction?

Also. Use blueprint.
It’s a hell of a lot easier to deal with to set up the silly UMG system.
/ if you punch it on Google you’ll get maybe only one billion tutorials of people doing it differently.

Or C) you didn’t actually read all of the unreal reflection / header tool documentation. It’s a fair amount – many sub-pages, about things like “BlueprintImplementableEvent” and DECLARE_MULTICAST_DELEGATE and many other things.

Unreal generates the non-virtual functions (and some virtual ones) for you.
You should not assume that whatever way of using virtual and non-virtual you have previously used, will work for Unreal.
If you’re good with C++, actually read the generated .h and .cpp files for your class. And follow up what all the macros do – some do surprisingly little, others do A TON.

The gameplay architecture documents I linked to, actually answers why this is. You need a derived PlayerController of some sort, and you need the PlayerController to call SetViewTarget() to whatever objects camera should be used. It could be itself. It could be a Pawn of your choosing. Pawns don’t even need to be physically simulated, nor do they need to have renderable components.

Also beware: “SetViewTarget” doesn’t set an object to target the view on, at all. It sets the object whose camera should be used by the camera manager. (You don’t need to override the camera manager; the default one is fine.)

If you follow the top-down or puzzle example/starter projects, they do almost everything what you’re asking for. Just open them up, pick them apart, and read the code!

Creating new projects is fast and cheap. Create the “top down” and “puzzle” starter projects. Read through them. Compare everything they do to the documentation. Unreal is a big and complex system, sometimes because it solves big and complex problems (and sometimes for historical reasons,) but the amount of documentation/sample material is actually pretty reasonable, as long as you pay attention, rather than assume that you know more (like with the C++ comment above.)

When getting to learn the built-in objects and functions, you may also be better off starting with blueprints/wiring. All of the blueprint functions are also available in C++, but the search/context functionality is much better. Right-click in an empty wiring space, type “Mouse” or “Cursor,” and see what comes up.

Or literally google “get mouse position in unreal engine” which ends up with this answer: Get Mouse Position | Unreal Engine Documentation

Unreal Engine: It’s not a library, it’s a life style! (And, honestly, it may not be for everybody. But it’s worth giving it a fair shake!)