Hi, I'm new to UE and apologize in advance if this quesiton has been asked a number of times before. I've googled, did not find anything that would give me a clue to solving this perticular problem, i've tried using many different things but nothing has worked. I am trying out the standard 3rd person template project using C++.
I have changed the character to content example owen character, the one that holds the gun, and attached a gun mesh to the character, right hand socket. Next in the blueprint, that i created from the C++ character class, I've added another C++ Arrow component, and parented that to the Gun, which in turn is parented to the Character mesh. In settings for the Arrow component I've set the parent socket to the 'muzzle' socket of the gun.
Now in my character.cpp, i've made a new input binding for firing a bullet / laser. and spawn actor works well.
The problem: The problem is the place to spawn. I've tried many different methods to get the Arrowcomponent and then get the co-ordinates, but nothing has worked. If i just do a GetComponents in the program and print that list to the console i can see the arrow component in the list, i've tried to cast it to UArrowComponent, to my class that is derived from UArrowComponent, but nothing's worked.
If i use GetArrowComponent() and then do the GetComponentToWorld(), it spawns the lasers at a..ahem..from the Inherited Arrow component co-ordinates..not very decent, anyway, that's not what i want anyway.
I've tried exposing a variable my customArrow type from C++ class and then set that to the custom Arrow in the character blue print, and the lasers are spawning but at a world 0,0,0, i suppose that is because i'm not passing my program the runtime instance and hence this behaviour.
Can anyone please suggest how can i get the custom Arrow component instance and the transform / vector location to spawn laser stuff.
Thanks in advance.
asked May 01 '16 at 11:26 AM in C++ Programming
I think i got around that problem.
Since my Arrow Component was a C++ class, i created static method that would return the instance of the class. Used that method then in the character class to get the instance and called ComponentToWorld etc methods on it to get what i wanted and there you go..
answered May 01 '16 at 03:11 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here