≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How to make rotation to camera smooth?
Posted by:
(you are not logged in)
Enter the missing letter in: "Intern?tional"
(you are not logged in)
Text:
[quote][b]dekon_17[/b] wrote: Let me explain first: I wanted to make weapons rotate when camera is rotating, but not instantly. I wanted to make something like in good old Bitsturbed. Just like that: [img]https://i.postimg.cc/9QBM4ZMY/s.gif[/img] As you can see, it rotates as it should. But, well, here's the problem: the .gif image here just can't describe how clanky this rotation is. I run this project on 60 FPS, and the .gif animation is 20, so, the real result is worse. I want to make this rotation a bit smooth, so that your eyes won't bleed looking at it (still, they will bleed if you'll look at this HUD). Here's the basic script: [code]/* <behavior jsname = "behavior_SmoothCamFollow" description = "Make the node smoothly rotate to camera direction"> <property name = "Cam" type = "scenenode"/> </behavior> */ behavior_SmoothCamFollow = function() { this.PrevRot = null; } behavior_SmoothCamFollow.prototype.onAnimate = function(node, timeMs) { var Rot = ccbGetSceneNodeProperty (this.Cam, "Rotation"); if (this.PrevRot == null) { this.PrevRot = Rot; this.ZeroAngle = ccbGetSceneNodeProperty (node, "Rotation"); } var NodeRot = ccbGetSceneNodeProperty (node, "Rotation"); if (Rot.y != this.PrevRot.y) var RotY = this.ZeroAngle.y + Rot.y - this.PrevRot.y; if (Rot.x != this.PrevRot.x) var RotX = this.ZeroAngle.x + Rot.x - this.PrevRot.x; ccbSetSceneNodeProperty (node, "Rotation", RotX, RotY, NodeRot.z); this.PrevRot = Rot; };[/code] I thought about dividing the "Rot - this.PrevRot" part by two, but this resulted "flickering" of object if I rotated so fast. So, how can I make it smooth? Little edit: I think about one solution now, and I'll try to make it, don't know will it work though.[/quote]
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