New answers tagged

0

According to the Unreal docs UCameraComponent you are correct, GetWorldLocation isn't part of UCameraComponent. Attached to the camera is a camera manager and to get the world location and rotation of the camera, you need to get this. APlayerCameraManager *CameraManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager; FVector ...


1

The Visual Studio Tools for Unity are primarily for writing C# scripts. They don't expose a C++ scripting API. The reason they show up when you're working with C++ in Visual Studio is they're related to VS, not C++ specifically. VS will let you develop in several different languages in a single installation, so they don't rule out the possibility that you ...


0

It turns out that before modifying vertex attributes (VBOs), I had to rebind the VAO of the created object. The modified render code looks like this: void Sprite::render() { // Set shader uniforms if the shader is initialized if (shader != nullptr) { applyTransforms(); shader->useShader(); shader->setMat4("transform", ...


2

This is not done with angles. This is done with vectors. Well, actually you could do it with angles... In any case, the ball has a velocity vector at the instant of collision, and will have a new velocity vector from the collision resolution. There are a few ways we can go about getting that new velocity vector: You can use vector projection to extract ...


0

This is fairly well documented in the SDL1 to SDL2 Migration Guide. Essentially, SDL_Surface is a tool for CPU side blit rendering, where as SDL_Renderer takes advantage of hardware acceleration, and performs the rendering on the GPU. SDL_Renderer provides an abstraction over several APIs and even offers a fallback CPU-side implementation if no other ...


0

Ok, I fixed it. It was a very silly problem. There was a project which where not well linked and all the projects were not using the same Runtime Library.


1

There are a few approaches you could take for testing rendering output. First, you could create a test mock version of your renderer, that instead of plotting things on the screen, would instead perhaps store some kind of representation of the rendering output, such as lists of renderer elements that you could assert against. This sort of approach is often ...


1

To add to Alex Coultas's solution, the final UProperty in the FSkeletalMeshMergeParams struct has to be BlueprintReadWrite like the others, otherwise you get yellow warnings in the output box. // Skeleton that will be used for the merged mesh. // Leave empty if the generated skeleton is OK. UPROPERTY(EditAnywhere, BlueprintReadWrite) class USkeleton* ...


3

Creating a seamless open world without loading bars is not an easy task. There are lots of small and large problems which need to be solved. This is not a beginners project! The basic approach is usually to divide the world into sections and only load those sections which are around the player. When the player moves around the world, new sections and their ...


0

You can try doing what you are now, but take the distance from the camera to the player, multiplied by the Camera forward vector to make it begin at the player. This should achieve what you want. Example, may not be correct or work but hopefully conveys the idea: float dist = FVector::Distance(PlayerViewPointLocation , GetWorld()->...


1

What I would probably do is using the inheritance mechanism of C++ and have a level superclass which level subclasses inherits from. The superclass contains virtual functions for creating, destroying, updating and rendering a level. You can then have a pointer to the current level so that only a single level is updated and rendered at a time. If each level ...


0

The easiest way is what you've done, then set the material in the Blueprint of whatever the material is attached to. Back in your .cpp file, you can then access the material. A word of warning though, if you're trying to change any settings and you haven't assigned anything in the Blueprint, Unreal will return the nullptr and crash the editor. To avoid ...


0

Instead of using the predefined GetPlayerViewPoint() to set your location and rotation, you'll need to use this: PlayerViewportLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation(); PlayerViewportRotation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorRotation(); This will set your parameters from ...


0

According to the SDL Documentation, your casting of Uint32 *pixels = (Uint32 *)Surface->pixels; only works if your surface->format->BytesPerPixel == 4. Your BytesPerPixel appears to be 3. Another clue as to it being only 3 bytes is that your aMask == 0. Your pixel array is only 3*N bytes wide, where N is the number of pixels. Since you're casting ...


1

In your text shader, you've forgot to set the sampler2D uniform's index. Each sampler in a shader need to be set to a specific index value, either at the creation of the shader (at the startup of the application) or each frame (not necessary, but possible). Whenever a sampler should be used in a shader, OpenGL needs to know what sampler to use, depending on ...


2

You create a window with default hints and context. See glfw documentation. Solution: first give the hints, then create the window. glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); glfwWindowHint(...


0

You need two scenes. It looks like you know how to render both viewports correctly; so I'll not cover that. You'll first render the main game view (the first scene), like you're currently doing. Now, instead of redrawing the same objects again for your mini-map, you'll need to define only a subset of your game objects so that you can render only those (...


1

As far as I know visual studio 2008 is the last version capable of building Windows Mobile and Windows CE applications. I need to support apps running on CE devices so VS2008 is still what I use. For my Windows Desktop apps I use VS2010 Pro for the simple reason than I own the licence. It works. I like it. and I don't see why I should fork out more money ...


0

My above suggested solution at the end of the question worked. I now have a new uniform: uniform bool B_tree; Which is used in the shader file as follows: if(B_tree){ vec3 offset = A_offsets[gl_InstanceID]; gl_Position = T_MVP * vec4(position + offset, 1.0); }else{ gl_Position = T_MVP * vec4(position, 1.0); } This uniform is being ...


2

There are a few solutions to this: limit the total number of attackable entities that can be active at any one time. This is one of the reasons why unit caps exist in RTS games. create a spatial partition so you can ask of the map "in a 50m radius give me every entity that is possible in this area" and then you loop over the resulting set to eliminate the ...


3

You can optimize this using spatial partitioning. The basic idea ist that you only compare those objects with each other which are within areas which are close enought to have a chance to collide. Divide your game world into sections. Store those sections in a data-structure optimized for directly accessing a section at a specific location. When your ...


0

As said in comments, what you are looking for is ptobably instancing: instead of gldrawElements you use glDrawElementsInstanced. The first thing you want too look for is probably this tutorial. They give an example of drawing 100.000 asterodis(!) with complexity of ~500 vertices with one draw call and still having excelent FPS. Without it the program chokes ...


0

Moving the invaders as one Something that @Krangogram has alluded to in their answer is that the individual invaders don't actually move by themselves, so one approach to efficiently move the invaders is to treat them as a single invader formation and the move the formation as a whole. You could define this similar to: class Invader { // x,y offset ...


0

When i created a Space Invaders clone, I moved the 'row' and then the enemy just had a fixed offset in X from that 'row' object. I think in the end I used just one object to cover all enemies with offset of X and Y.


0

I found what I messed up. It seems that glm::translate(mat4, vec3) doesn't do what I though it does. What I thought it does is that it takes the provided mat4 and vec3, treats the mat4 as a transformation matrix, and applies the translation described by vec3. It obviously works in some other way (or there is a detail I have missed that breaks it in the way ...


0

Thanks to anyone that took the time to answer my question, but I wanted to answer it myself for future people interested in a potential solution - I replaced each instance of rand() % 200 + (-200) In my question code (for the randomized x and z values of the Vector3f object) with the following: -200 + static_cast <float> (rand()) /( static_cast <...


1

rand() % 200 yields a random number between 0 & 200. rand() % 200 + (-200) takes the range above and shifts; think of it as adding -200 to both the min possible outcome & the max possible outcome. Thus, 0 to 200 becomes -200 to 0. To get a -200 to 200, first, note the size of the range is 400 units. So you start with rand() % 400. Next shift it ...


Top 50 recent answers are included