Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
I used a script that fixes a problem related to horizontal rotations. Please modify it so it also works for vertical rotations!

wild-master
Registered User
Quote
2017-09-24 18:34:44

just_in_case wrote:
Here is the sample ccb file in which a cube follows another cube with respect to the rotation of the another cube...

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


I tried your file, and when I added the ability to do vertical rotations to the object, the same problems that I've already discussed happened!


just_in_case
Moderator
Quote
2017-09-24 19:25:23

What do u mean by vertical roation , do you mean that... The object isn't rotating along z axis or y axis... When i tested ccb the rotation for upward and downward direction are working fine... Or maybe you mean something else by vertical rotation... Which am getting wrong..


It will be more easy for us to understand what you exactly want to do if you provide aome screenshot or refrence images from other games.. so that we can get an idea what exactly you want to do with rotations..


wild-master
Registered User
Quote
2017-09-24 21:18:32

just_in_case, I modified your file to portray my problem.

Please download it here:
https://drive.google.com/file/d/...

When you use the WSAD keys to move around the whole area, you will be able to see what my problem is! The rotations will become destroyed!


just_in_case
Moderator
Quote
2017-09-24 21:20:57

Awkey,..... I will check the ccb tomarrow.. its already midnight here...


just_in_case
Moderator
Quote
2017-09-25 07:53:12

Just tested the modified CCB you have posted yesterday... ....

There was no problem with the coding itself but the problem was with the the move when collide behaviour, Un-tick the Enable Inclination option and then the Cube will Rotate vertically also...

And for the Jittering movement of the Cube , You have enabled gravity for the one cube and had disabled it for the other cube in my CCB file Modified by You...
The Cube was trying to go the "y" position of another cube but as affected by gravity it will forced to move down... Which produces the Unstable movement ...

So I disabled inclination and affected by gravity for both of the Cubes and the results are the cube is rotating horizontly as well as vertically...
but when the inclination is turned on the cube doesn't rotate...
so disabling Inclination will solve the problem...


Download the New CCB From Here...
https://drive.google.com/file/d/...





wild-master
Registered User
Quote
2017-09-25 13:54:14

It still doesn't fly correctly in your file.

Please try this with your file:
1. Press the W button six times. The object's vertical rotation will be perfect. That's how it always should be.
2. Now, press the A button ten times.
3. When you press the W button now, a different side of it will rotate vertically! Imagine a plane. The same side of the plane should always be the front!

Now, please close the game, and press the Test button again to restart the example, and then do this:

1. Press the A button six times. The object's horizontal rotation will be perfect.
2. After that, press the W button ten times.
3. Now, press the and hold the A you will realize that the horizontal rotations won't work correctly! The A button originally rotated the object toward the Left, but it now moves the object vertically!

(Reminder: The Behavior for the D button is set to 0, 0, 10, but it should be 0, 10, 0. That mistake was my fault. It was in the original file I gave to you.)


just_in_case
Moderator
Quote
2017-09-25 15:45:09

Okay, Now i got it...

one thing can solve your problem if we can transform the axis itself.... for example when the object rotates to z axis swap or inverse the Y and X axis...


just_in_case
Moderator
Quote
2017-09-26 08:23:21

didn't found a perfection solution to the rotation yet... bu there is a workaround to achieve something to vertical and horizontal rotation...


use variables...

if rotation Z = 90 then set a variable suppose "rotateY" =1
if RotationZ = 180 then set a variable suppose "rotateY" =0

Now when a key pressed down "A" for Horizontal rotation do something..
if variable "rotateY" = 1 then do something
currentScenenode
Change Rotation of a scenenode
rotation should be 0,10,0

if a variable "rotateY"= 0 then do something
Change Rotation of a scenenode
currentScenenode
Rotation should be 10,0,0


now if you rotate the object then its horizontal rotation will work fine..

the results will not be that good.. but they can be tweaked for better rotation by using more variables...

otherwise if there is an option to translate the Rotational axis to cordinate axis....
then the desired result can be fulfilled...

but i don't think there is option to transform the axis...


wild-master
Registered User
Quote
2017-09-26 22:34:48

just_in_case, I tried to follow your instructions and it didn't work, so I probably didn't implement your idea correctly.

I've been trying other methods for the past five hours. One of the ideas I tried is to create an object that moves in a circle by attaching the "Fly in a circle" Behavior. I wanted to set its normal speed to zero, and when my Left button is pressed, it would move backwards around its horizontal circle, and when my Right button is pressed, it would move forward around its circle. I placed the center of the circle at the "0, 0, 0" position, and I set the radius to 20,000, so it's extremely large. This means that my character would always be within the circle because the level would fit inside of it, so the object's position around its circle could be used as a navigational guide.

I wanted to use the "moveto" feature of the ccbAICommand() function to move my character toward the current position around the circle. I wanted to always use a different variable to track the vertical position, based on when the Up and Down buttons are pressed, so the horizontal position of the object around the circle would be combined with a separate Vertical variable to provide a location for my character to follow with the "moveto" feature of the ccbAICommand().

I tried to do all of that, but the "Speed" and "Direction" properties of the "Fly in a circle" Behavior cannot be changed within our games. I tried to change them within the editor based on the values of variables, but that ability is only possible for "Actions". The "Fly in a Circle" feature is a "Behavior", so it cannot be used like an "Action".

I wanted to do this:
If A button is pressed,
"Fly in a circle" feature is used, with speed set to 1.

If D button is pressed,
"Fly in a circle" feature is used with same variables as before, but speed is set to -1.

If A button is NOT pressed and D button is NOT pressed,
"Fly in a circle" feature is used with same properties as before, but speed is set to 0.


I'll summarize that plan here:
1. I wanted to create an object that can be moved in a circular motion far beyond the perimeter of each level. Since my character will always be within that circle, the position of that object could be used as a navigation point by forcing my character to move toward it with the ccbAICommand() function. The movement of CopperCube's Artificial Intelligence has perfect rotations.

I'm considering ceasing my attempts to achieve this goal by doing this:
I could use the built-in First-Person camera, and coerce Niko to allow me to disable the included movements of the WSAD keys, because I don't want those motions to be included in my game, and I want to be able to reuse those keys for other reasons. I also want to persuade him to include the same mouse viewpoint of the First-Person camera to a Third-Person camera. He has a Third-Person camera with mouse movements in the official downloadable extensions page, but it's meant for Top-Down games because it only registers the X and Y coordinates. It doesn't work for 3D viewpoints like the First-Person camera does. If I attach a character as a Child node of the First-Person camera, creating a Collision sphere around it will be very hard!

Niko, how much work is required to allow Child nodes to report their current positions to the engine? If an object is a Child node, the same position will always be reported when we use the ccbGetSceneNodeProperty() function! Would allowing them to report their newest positions, just like regular nodes, waste a day of development time? It would allow so much more freedom to me!


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