Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assign a Camera to a Unit?

12 REPLIES 12
Reply
Message 1 of 13
Karlo456
587 Views, 12 Replies

Assign a Camera to a Unit?

Hi all,

I am trying to link a camera with a Unit, so that when I click on a Unit(Chamfbox2.2), the view switches to the assigned camera view(Camera4). Attahced below is the flow for reference.


I followed 2 videos, the first video is for allowing for mouse picking, and the second video is for setting up a camera:
https://www.youtube.com/watch?v=dtpY_3-eGs0
https://www.youtube.com/watch?v=tsBP7OrAXZM


The two flows work individually (Thanks for the awesome tutorials by Dan Matlack!). I tried to combine them and the flow does not work in Test Level. When I click anywhere on the screen, the window switches to the assigned camera view(Camera 4). However, I want to switch views only when I click on the specific unit(Chamfbox 2.2). Anyone can provide help with this issue?


Any input would be greatly appreciated. Thank you. 

Tags (2)
12 REPLIES 12
Message 2 of 13
Karlo456
in reply to: Karlo456

Sorry, I'm not sure if the picture was properly attached, so have attached again. Thanks. 


@Karlo456 wrote:

Hi all,

I am trying to link a camera with a Unit, so that when I click on a Unit(Chamfbox2.2), the view switches to the assigned camera view(Camera4). Attahced below is the flow for reference.


I followed 2 videos, the first video is for allowing for mouse picking, and the second video is for setting up a camera:
https://www.youtube.com/watch?v=dtpY_3-eGs0
https://www.youtube.com/watch?v=tsBP7OrAXZM


The two flows work individually (Thanks for the awesome tutorials by Dan Matlack!). I tried to combine them and the flow does not work in Test Level. When I click anywhere on the screen, the window switches to the assigned camera view(Camera 4). However, I want to switch views only when I click on the specific unit(Chamfbox 2.2). Anyone can provide help with this issue?


Any input would be greatly appreciated. Thank you. 



 

Message 3 of 13
funfrank4591
in reply to: Karlo456

the camera that you are trying to switch to, is it attached as the child of your object or do you want to switch to any specific camera in the scene?

 

Message 4 of 13
funfrank4591
in reply to: funfrank4591

 am trying to create a similar scenerio without using any code

 

Have taken two cameras and two object from basic scene chamfbox and basic floor.

first module casts rays and detect the object and second sets the cameras.

 

Not sure if this is the solution you require.

 

Thanks.

 

 

 

-----------

Thumbs up if you like this.

Message 5 of 13
funfrank4591
in reply to: funfrank4591

.

Message 6 of 13
Karlo456
in reply to: funfrank4591

Apologies, but I am a beginner and do not have much knowledge of parent and child. But basically, for example if I click Unit A then the view will switch to Camera A, and I can still move around the scene. When Unit B comes to view, I can choose to click Unit B and the view will switch to Unit B, and so on. All the units are static.

 

I want to do this effect as the model I am working on is large and it would save a lot of time walking around by having some shortcuts. 

 

So I guess that means  I want to switch to a specific camera by clicking on their associated units. Hope this somewhat answers your question. Thanks. 

Tags (2)
Message 7 of 13
Karlo456
in reply to: funfrank4591

Thank you so much for the examples, I am trying them out now. Just want to check, what is the script under "Script Do String"? Also, in Level Loaded, where does the middle link connect to?

 

Just some additional info, I don't think it can be seen in my flow screenshot, but initially I set it up whereby I am moving around the space and can look around, only when I press "c" the scene freezes and the cursor appears, and I can click the object. (I could make the object appear/disappear, but I could not associate a camera to it by clicking it).

Message 8 of 13
funfrank4591
in reply to: Karlo456

Level loaded connects to other module which is not required here.you can leave it.

The script do is used to call stingray inbuilt function "stingray.Window.set_show_cursor(true)"

so you need not to write lua code which you were following in the video to display cursor.

you can use any button to to toggle this behavior along with the camera freeze.

 

 

just edit script string and enter: stingray.Window.set_show_cursor(true)

This will show cursor in the window 

 

 

----------------------

Thumbs up if you like this.

Message 9 of 13
Karlo456
in reply to: funfrank4591

Hi funfrank,

 

Unfortunately I tried your method and it is still not what I need. In test level, the view switches to the camera when I click anywhere on the screen. Does this happen to your sample project as well?

 

However, I need it so that only when I click on ChamfBox(Unit) then the view changes to camera 1. Am still trying to figure out how to create the desired effect 😕

Message 10 of 13
Shanii2
in reply to: Karlo456

Thats more of programming sort of thing than setting up cameras. Using flow you can do this pretty easily watch the tutorial of mouse picking in Autodesk stingray game solution channel. They have done it with flow using raycast. I'm just going to tell how to achieve after you've done that tutorial. After the raycast collides with your chamfbox you check with Boolean weather is that same chambox with camera attach. And when it's true your going to trigger Set active camera and point to one that's aiming the chamfbox. You can add an additional keybored input to set the camera back to default. Try it.
Message 11 of 13
funfrank4591
in reply to: Shanii2

I have attached the project file here , you can check out.

Also check the string data in the unit editor which is used to uniquely identify object.

 

 

https://drive.google.com/file/d/0B1MQcJBonLxfNWtzdW4weEFIU0U/view?usp=sharing

 

 

 

-------------------

Thumbs up if you like this.

 

 

Message 12 of 13
Karlo456
in reply to: funfrank4591

Hi Funfrank and Shanii,

 

Thank you for the input. Have tried out the project file and it is something close to what I wanted. Now I just need to try it with the HTC Vive haha. Will update when possible. Cheers!

Message 13 of 13
funfrank4591
in reply to: Karlo456

@Karlo456 good to know that .All the best for your project.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report