Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
rotating an object in a group by mouse control

creaturefreak
Registered User
Quote
2018-09-12 15:38:44

Hi there. Is there a way to use the mouse to rotate an object that is currently in a group like the "First person shooter style control".

I've tried to do this by making a "First Person Shooter camera " a child of another camera and using the action: change "active camera". It changes the child Camera however the Camera does not rotate the object, it seems to be locked. Even when the second "first person camera" is not parented to another camera, and the "change active camera" is invoked the camera moves the object but does not rotate it with the mouse.....bug?

The idea is to be able to take control of a child object and use the mouse movements to control it. rotating it any direction. like a turret on a tank but not having to rotate the whole tank.

Just curious if this can be achieved.

thanks

CF


just_in_case
Moderator
Quote
2018-09-12 16:04:46

This can be easily achieve by scripting... I will probably write a behavior for this.... I have some work to do outside the town... Will try to create this behavior after 3-4 days.... Hope you won't mind waiting for this long...😇


ishmaru
Guest
Quote
2018-09-12 22:35:18

Keep in mind that coppercube will ignore any behaviors on a camera that is not active. So you can't use this method


creaturefreak
Registered User
Quote
2018-09-13 09:07:30

just_in_case wrote:
This can be easily achieve by scripting... I will probably write a behavior for this.... I have some work to do outside the town... Will try to create this behavior after 3-4 days.... Hope you won't mind waiting for this long...😇





"Just" Man that would be very kind of you. I'm not much of a scripter so any help would be great.

best,


just_in_case
Moderator
Quote
2018-09-17 19:51:48

Will start working on this from tommarow morning... And will upload it in 2-3 days.. it took me longer than i expected to work outside of my hometown...
Now as i returned back to my hometown i will start making this action/behaviour....


creaturefreak
Registered User
Quote
2018-09-18 07:36:58

just_in_case wrote:
Will start working on this from tommarow morning... And will upload it in 2-3 days.. it took me longer than i expected to work outside of my hometown...
Now as i returned back to my hometown i will start making this action/behaviour....


Hey Just! can't thank you enough. We appreciate all your post and help on these forums. It's a small community and some of us are not good scripters, so every little help is much appreciated..thank you.

CF


just_in_case
Moderator
Quote
2018-09-18 09:51:33

here is the example ccb file with the action to rotate an object horizontally...
this is a turret example you can rotate the turret using mouse and click to shoot....

if this is not what you want then please explain in more detail.. or a video reference will be fine..

https://drive.google.com/file/d/...


creaturefreak
Registered User
Quote
2018-09-18 15:57:17

just_in_case wrote:
here is the example ccb file with the action to rotate an object horizontally...
this is a turret example you can rotate the turret using mouse and click to shoot....

if this is not what you want then please explain in more detail.. or a video reference will be fine..

https://drive.google.com/file/d/...


Hi Just, Thank you for the great script. It's very cool. In detail what I imagined would be is to be able to move and rotate the sentry object in a direction and then be able to rotate the "Gun" either 180 degrees or 360 in the in the direction the "Sentry is facing" right now the Rotation is good only when the Sentry is moving back or forward but not when it is rotated. Also being able to rotate the "gun" a little bit vertically would be great. If it's to difficult to achieve , then please don't worry about it .

Here's video of what I mean https://youtu.be/rvVPm3dAbWQ



here's the modified ccb file which is adjusted to rotate the sentry object with the left and right arrow keys,
also you have to hold down the right mouse button and move the mouse to rotate the gun .https://drive.google.com/file/d/...


just_in_case
Moderator
Quote
2018-09-18 17:57:19

Hmmm... Will try to solve that tommarrow...and yes it is also possible to rotate the gun vertically ..


creaturefreak
Registered User
Quote
2018-09-18 18:20:17

just_in_case wrote:
Hmmm... Will try to solve that tommarrow...and yes it is also possible to rotate the gun vertically ..


Ha ha...I made it work however it's very sloppy the way i did it. I detached the "gun" from the "Sentry". The "gun" follows the "Sentry" now with "every second do something/change position of a scene node..relative to "Sentry"

Both objects have the behavior "object or person controlled by key board"
except the "Gun" has the moveSpeed set to "0". With the action "Rotate an object using mouse"

Just_In_Case maybe there can be an action script that combines all this into something cleaner.

check out the ccb file..don't forget to click and hold the right mouse button to rotate the "gun.



https://drive.google.com/file/d/...


just_in_case
Moderator
Quote
2018-09-18 19:12:59

haha glad that you have figured out a way to do this by yourself.. as you are using a key pressed and variable to execute this action... it may not be possible to embed all this into the same action script...

currently you have to use the same method or you can use java script by registering on frame event then changing position of your gun node to the position of sentry... it is a bit same as your current method...

if you need any further help then please let me know.


creaturefreak
Registered User
Quote
2018-09-19 01:23:21

just_in_case wrote:
haha glad that you have figured out a way to do this by yourself.. as you are using a key pressed and variable to execute this action... it may not be possible to embed all this into the same action script...

currently you have to use the same method or you can use java script by registering on frame event then changing position of your gun node to the position of sentry... it is a bit same as your current method...

if you need any further help then please let me know.


Thanks for the help "just". I may need a little help with your script "Rotate object by mouse" can you add vertical rotation option to it in degrees possibly like the horizontal option you put in? An example it could shoot a flying enemy..or a sentry on a building at higher level?

Thank you again for all your help.

CF


just_in_case
Moderator
Quote
2018-09-19 06:01:04

if you look into the script you will find that i have already comment out the code... all you need to do is to change the rotation on the x axis ...

you can find the script file in your coppercube extensions directory name as Action_movewithmouse.js open it with any text editor and you will be able to edit it to make the object rotate vertically...


creaturefreak
Registered User
Quote
2018-09-19 06:42:59

wrote:
if you look into the script you will find that i have already comment out the code... all you need to do is to change the rotation on the x axis ...

you can find the script file in your coppercube extensions directory name as Action_movewithmouse.js open it with any text editor and you will be able to edit it to make the object rotate vertically...


Thanks "Just" I have the script but cannot see where I need to change the rotation on the x axis. As I mentioned before I am not good with scripting and learning a little here and there. Can you tell me which line in the code I should change and into what?
No worries if you do not want to post it, I can deal with only horizontal rotation.

thanks

CF


just_in_case
Moderator
Quote
2018-09-20 13:16:44

Sorry, i somehow missed your post....

you have to change this line of code..
ccbSetSceneNodeProperty(this.Scenenode,"Rotation",rotation.z, degree + this.AdditionalRotation, rotation.z)


change
rotation.x
to
 degree + this.AdditionalRotation


and
 degree + this.AdditionalRotation 
to
rotation.y


this will make the turret goes up and down (vertically)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact