UE4 Attach actor (or his component) to another actor (or his component) - unreal-engine4

So, the setup i have is simple. I'm making a VR darts game, sortof, using the default VR template, and i have a DartActor, with an attached ConeMesh (StaticMeshComponent) used for the dart, as well as a TableActor with an attached CylinderMesh (StaticMeshComponent) used for the dart board, as well as a RotatingMovementComponent.
When I detect an overlay between the two, I turn off physics on the dart (because otherwise it just bounces off) and try to attach it to the table actor. I have tried the following:
"attach actor to actor", when I try to attach the dart actor to table actor
"attach actor to component", when I try to attach the dart actor to TableActor's mesh component
"attach component to component", when I try to attach the DartActor's root component or mesh component to TableActor's mesh component or root component.
Neither of those worked well for me.
But disregarding that, turning off physics on the DartActor when an overlay is detected successfully fakes the dart sticking in the table. With one minor caveat - when the dart is seemingly stuck in the board, the board is still spinning underneath the dart.
I used the "Snap to Target" for both the location and rotation, and just kept "keep relative" for scaling on the "Attach" blueprint node.
What I'd like to have is, the dart actually sticking to the table, welding, and rotating with the table (dart board) while it's also rotating.
So, how do I do that?
I'm using UE4.27.2, if you need the blueprint screenshots just lemme know.

Ok, I fixed it.
It turns out it was a combo of other misc slipups...
The StaticMeshComponent needed to be the root component instead of the default RootComponent - for both the DartActor and TableActor
I used AttachActorToComponent in the DartActor's Blueprint, using the DartActor's self and attaching to the TableActor's StaticMeshComponent
In the actual AttachActorToComponent BP node, I used "Keep World" for all three things (location/rotation/scale)
I kept the "Set simulate physics" to OFF on the DartActor itself, before attaching.
And that's it, the darts are now sticking to the board and rotating along with the rotating board.

Related

MRTK 2.7.3 - Outline Shader is not visible on HoloLens

I saw the scene OutlineExamples in the MRTK examples package and recreated it in my own project.
The outlining works if I stay in unity in play mode. But if I deploy it on the HoloLens the object does not get a outline effect.
The OutlineExamples scene from the MRTKHub-project works as excpected on the HoloLens!
So I guess I missed something in my own project, but I cant find it. I compared the setup multiple times, but cant find a difference. And I also used the simplest object (the cube) from the example scene.
Setup for the cube
(the screenshot shows on the left side my project and on the right side the mrtkhub-project):
Mesh Filter (standard)
Mesh Renderer (standard)
Box Collider (standard)
MeshOutline with the Material "OutlineOrange" or "OutlineGreen" (added)
Object Manipulator (added)
Constraint Manager (added)
The only thing that I had to setup after adding the as "added" marked compenents, was the material for the MeshOutline component.
Is there something else someone has to setup to see the outline shader on the HoloLens?
My Setup:
Unity 2020.3.30
MRTK 2.7.3
Visual Studio 2019
What else did I check?
The XR Plug-in Management is set up the same way
--EDIT
I noticed something strange and I guess this will help someone who knows more about shader!
I launched my application on the HoloLens, grabbed the cube and put it in front of a window in my room. While placing the cube in front of the window, I saw the outline! But as soon as I move it outside the window area, the outline disappears! Another aspect is that I'm using the spatial mapping from MRTK. That means that the window does not get meshed, only the walls. And I guess the walls have their own shader on it, right?
So the spatial mesh shader and the outline shader "dont like each other". Is this possible?
The user derHugo gave me a hint that led to the solution! I went to the material, that I use on the cube and changed the property Render Queue Override under Advanced Options to a higher value than the material MRTK_Occlusion, which is used for the spatial mapping, has.

Cannot Animate Interactable Gameobject using Mixed Reality Toolkit

I am a bit of a novice with the Unity Engine and Mixed Reality App development so please bear with me.
I have been working with the Microsoft Mixed Reality Toolkit for Unity to try and animate a game object and move it to the side. A simple action, very similar to an example scene provided by Microsoft with the toolkit called "InteractableObject" (Information links provided below)
Interactable Object - Mixed Reality (Microsoft Docs)
Mixed Reality Toolkit-Unity Interactable Objects and Receivers (Github)
This example scene in Unity has multiple objects to be used as "buttons". With the Mixed Reality Toolkit, even objects that you want the user to interact with to perform some sort of action when selected is even considered a button. At least according to the documentation I have actually been able to find on the subject. This is a series of screenshots depicting the inspector panels for my GameObject and the container for my object:
GameObject Inspector Panel
GameObject Container Inspector Panel (Part 1
GameObject Container Inspector Panel (Part 2
I am trying to make a single game object move to the side when I place the standard cursor on it. This same action is done with a balloon object in the example scene I mentioned. I have created the animator and the state machine the same as they did in there example as well as setup my game object in an almost identical format. Only real difference is that created a balloon object themselves and I am using a different set of custom models from my company.
When I attempt to play back the app in the Unity Editor, the state does not change when I place the cursor on the object. I can force the state to change using the editor and the required animation engages, but it will not change the state on its own. I configured my state machine the same as the Microsoft example and setup my state variable the same as well. It should move from an "Observation" state to a "Targeted" or "ObservationTargeted" state when the cursor moves onto the object. A screenshot of the GameObject state machine and the inspector panel of the specific transition in question are provided below:
GameObject Animator State Machine Setup
Observation to ObservationTargeted Transition Inspector Panel
I went through and verified that all components added by the Mixed Reality Toolkit are the same and they are. This includes the DefaultCursor, InputManager, MixedRealityCameraParent and Directional Light. I also checked that all the scripts were coded the same as well and they are. I am running out of places to look. I attached the Visual Studio debugger to the project in Unity and have verified that it just isn't changing the state on its own. But I cannot figure out why. I believe the problem has something to do with the setup of the transition, but I haven't been able to find the issue. All of the other mentioned components are provided by Microsoft and are not changed by myself nor are they changed in the sample scene.
If anyone else has had a similar problem or may know where I can look to find the problem please let me know. I haven't even built the project into an UWP application yet.
I know it's been a few months, but do you still looking for the solution?
With the newest version of Mixed Reality Toolkit you could make any GameObject to act as a button. Simply read this documentation. I have some cubes as buttons in my Unity project and the only extra Component I added to it to make it work was Interactable, which comes from Mixed Reality Toolkit.
If you want to trigger some animation when you place the cursor on the object (or look at it if you're going to use it with Hololens) then you can add them in Interactable object by adding a new Event (for example: OnFocus() event)
Hope this helps is any way

How do I force orbital movement around a point in space, while maintaining forward/backwards capability on a player?

Long-winded question out of the way, I'll provide a diagram of what I am going for:
The red square represents the character, the blue rectangle represents the camera, the green dot represents the center of the "stage", and the black circle is the stage itself.
What I desire is to essentially lock the player's movement around the "center" of the stage, so that anytime you move left or right you are more or less rotating around said center. However, I also want the player to be able to move forwards and backwards to/from the center as well. Keep in mind I want the camera to always stay directly behind the player. I have tried many different methods, and the latest is the following:
I took a default actor, attached a spring arm, attached a child actor to that (gets possessed to become the playable character), attached another spring arm, and finally the camera to that. I then added the blueprint code to the first spring arm so that it was the one being controlled by the left/right controls. However, upon hitting play, the only thing that moves is the camera, and it can only move forwards and backwards.
I'm admittedly pretty new to Unreal Blueprints, so any help would be appreciated.
Alright, I figured it out.
Here's the setup needed if anyone else wants something similar.
For the player themselves, you'll need something like this:
The important thing is to center the root mesh where you want to rotate around. The spring arm's target arm length will be affected for the player mesh movement, giving the illusion you are physically moving the character. The second spring arm isn't necessary unless you wish to have more control over the camera to player distance.
For the rotation Blueprint, you'll need this:
The target is whatever you named the root mesh. (Mine was called Center) Drag and drop it from the hierarchy.
For the forward/backward movement, you'll need this:
The target is what you named the spring arm. (I left mine as the default "SpringArm") Again, just drag and drop it from the hierarchy.
Adjustments in Project Settings:
Yes, my inputs are backwards from what you'd think. I felt it was quicker just to reverse the inputs instead of adjusting whatever was causing the movement to be backwards in the first place. (It's probably just the sphere orientation.) Also, you'll notice I have the w and s inputs set to 5 or -5 instead of 1 or -1. This is due to the fact the movement was slow otherwise. I'm sure there's a fix that doesn't involve changing the input axis scale, but honestly I won't really have a reason to alter the values at any point in my project. If it ever comes up where I do need to, I'm sure there's a bypass to change the values from within blueprints anyways.
End result:
End Result Video
If I remember correctly, child actor components are a bit different from other components in that they are transformation independent, that is they do not update their transformation when their parent component moves around.
I find it a bit strange that you would separate your player actor and the camera component. Normally, the player "pawn" contains the mesh and camera components for one player.
I would suggest you do the following:
Create a player actor (e.g. a "pawn" or "character" class)
Create the following component hierarchy:
Root Scene -> Spring arm -> Skeletal or static mesh -> spring arm -> camera
Your root scene is the green center in your drawing. You can then basically use the blueprint you already have to rotate and move your player.

Unreal How to make my static mesh undestroyable in run-time unreal?

I created unreal game and it have a option that can select objects that you need to place on the floor from a widget menu. And it also have a option to remove the objects that placed on the floor when pressed "R" key. My problem is when I place my tracer on the floor and press "R" it also remove the floor and then character start to falling down. So, anyone no how to remove only selected objects and not everything in the game.
I think that you should create a new class (C++/Blueprint) for your 'destructible' static meshes. Then while tracing you could try to cast the object you're pointing at to newly created class and if casting is successful, destroy it.
You can either use "Actor has tag", but then you'll need to add the tag on each individual actor you want to affect.
You can edit channels in the Project settings -> Collision, make a new channel specific to things you want to affect, and then change the collision settings on the actors and on the linetrace.

NavMesh baking finished very quickly and does not include some objects

I am doing one of Unity's official tutorials: Survival Shooter.
Unity version: 5.3.4f1 Device: Macbook, OSX 10.11
http://unity3d.com/learn/tutorials/projects/survival-shooter/environment?playlist=17144
The problem: Baking process completes almost instantly and the floor is not highlighted by a blue mesh (where highlight should mean that navmesh is calculated for there).
Here is the screenshot of it:
Then, I checked the completed scene (which was already created by Unity Team), it showed the floor fully highlighted. I just hit the bake again without touching anything and the same problem happened. So, there must be something else as I tried the original scene file without changing anything.
What am I missing here? Is there a Unity editor setting or something like that which can break the baking process?
When baking a NavMesh for your game, a crucial thing to verify is that every object which should affect navigation is marked as a Static GameObject, or at least Static for Navigation. This setting may be found in a checkbox/dropdown at the top of the properties Inspector:
It sounds like the floor object in your scene hasn't been marked as Static, meaning it won't factor into the NavMesh baking.