# need a macro or function

**URL:** <https://forums.unrealengine.com/t/need-a-macro-or-function/482482>\
**Category:** Cinematics & Media\
**Tags:** target, get, macros, unreal-engine, question\
**Created:** [April 26, 2021, 6:34pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482 "2021-04-26T18:34:36Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 6:34pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/1 "2021-04-26T18:34:36Z")

</div>

i need a macro that checks if a cam is active or not. if firstperson is not active use thirtperson if thirtperson is not active use first person…

im now by the macro creation windo but i cant find the camera…what is the camera as input? or can smd shortly build this macro ? ty

 ![337168-get-active-camera.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/b/bdb73c588b683c8fa19919acc6cb5da477cd6de7.png)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 6:47pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/2 "2021-04-26T18:47:35Z")

</div>

i tryed select object but it cant be combined and a select component doeset is there as function yet. i try a select component macro maby…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 6:50pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/3 "2021-04-26T18:50:58Z")

</div>

Maybe you can adjust your requirements slightly, because both cameras are always active ( in this case ). It would be better to have a variable that you flip when you switch characters. A central place for that would be the game instance.

Then, you can write a macro, but… I just tried that, and you get in a mess because you can’t have a local camera component variable. You can keep a reference to the current camera in the game instance though, so you might as well do the whole thing there ( including swapping players ):

Then, getting the camera is just:

![337170-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/8/1487afefa4a0cbd26205052009785fca3f2a2982.jpeg)

and

 ![337171-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/9/c3999ebf55efdac308aa92403f0ec1dcd641cf14.jpeg)

I didn’t do the player swap, because I don’t know how you’re doing that…

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 6:56pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/4 "2021-04-26T18:56:30Z")

</div>

im now at this point but idk how to do the is active param

 ![337172-how-to-set-is-active-param.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/5/0954a30e47840e545872fadf5fa8fd9b61374c29.png)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:09pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/5 "2021-04-26T19:09:45Z")

</div>

btw i can use ,is active" as param but the -get world rotation- gets an error when connected to

-new param3- it says target must have a connection lel

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 7:10pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/6 "2021-04-26T19:10:55Z")

</div>

Does it work?, like I say, I think they’re both active if you have both players in the world.

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:27pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/7 "2021-04-26T19:27:22Z")

</div>

it not work. its the fire mechanic that chooses the rotation of the active camera. when i switch from frist to third person i need it to fire with the Y rotation. the -get world rotation- seems not to find the imput of the scene components as it says errror all the time…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 7:29pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/8 "2021-04-26T19:29:03Z")

</div>

Ah! - this is all 3rd person then? You have 2 cameras in the third person character?

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:32pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/9 "2021-04-26T19:32:52Z")

</div>

![337173-error-isnoscenecomponent.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/3/c/63c80eeebcc2bd28a6cbd107722972df0926eb83.png)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:34pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/10 "2021-04-26T19:34:22Z")

</div>

i have a first and a third person cam for single player mod. and when i switch the cameras the fire mechanic needs to switch the cam input to get the rotation to fire with

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 7:34pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/11 "2021-04-26T19:34:51Z")

</div>

If you’re doing it all in the third person character, much easier with a function:

 ![337174-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/b/b4b3254f76e7356cfe56ced5c3dfaee6dd5add4a.jpeg)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:41pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/12 "2021-04-26T19:41:26Z")

</div>

ye i can do that with a branche but im basicaly in the first person that switches to third person and back. to do it with a true falshe exe means that i need to double the whole fire mechanism.

to reduce the code i thought i could find a way to pick up the active camera at the ,get world rotation".

but if there is no trick for that i might need to branch it

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 7:44pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/13 "2021-04-26T19:44:53Z")

</div>

Wherever the function is, you can use it like this:

![337175-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/2/6e2e17418f7bf955adc042eb1ae6bd61f435405d.jpeg)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:54pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/14 "2021-04-26T19:54:57Z")

</div>

i not see get active camera Oo. the project was startet as first person but it still not shows me active camera …anyhow i solved it with a branch. needed to dublicade the tree to catch the rotation of both cams. i let this topic open for macros and scripts

 ![337176-solved.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/4/8445f47e2a2924322024813d7c707f044db9993b.png)

---

<div class="post-metadata">

**Author:** ![blendernuuub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blendernuuub](https://forums.unrealengine.com/u/blendernuuub)\
**Post date:** [April 26, 2021, 7:57pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/15 "2021-04-26T19:57:49Z")

</div>

ingame it works perfectly 😃

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 26, 2021, 7:58pm UTC](https://forums.unrealengine.com/t/need-a-macro-or-function/482482/16 "2021-04-26T19:58:34Z")

</div>

GetActiveCamera is the function I just showed you how to make… no branch…
