Git Product home page Git Product logo

Comments (5)

aladvs avatar aladvs commented on August 16, 2024

A simple fix to this issue would be adding a new parameter called something like "keep previous transform". This allows rotation and scale of the node to be edited, while still not affecting any things that are enabled.

Under process, it would be

func _process(_delta):

	var f = Engine.get_physics_interpolation_fraction()
	var tr: Transform3D
	if SF_KEEPTRANSFORM:
		tr = transform
	else:
		tr = Transform3D()

instead of:

func _process(_delta):

	var f = Engine.get_physics_interpolation_fraction()
	var tr: Transform3D = Transform3D()

from smoothing-addon.

lawnjelly avatar lawnjelly commented on August 16, 2024

I discuss this in this video for the core interpolation in 3.x:
https://www.youtube.com/watch?v=BJgDCISku_o&t=126s

For FPS camera and the addon, sometimes it can be better to keep the camera on a separate branch to the player, and manually interpolating in global space. Attaching the camera as a child of a (basis) smoothed player visual rep won't work well as you say, because the smoothed basis will likely be inherited from the parent, unless you turn off basis interpolation.

Typically in FPS you'd want to drive the rotation of the player (rather than the camera directly) using the mouse, so if you turn off basis interpolation in the player, and just alter the yaw of the player directly using the mouse (and thus inherited by a camera child) this may work for you. The pitch on the other hand might be applied directly to the camera, so the player rep is always level but the camera looks up and down. The exact setup depends on the nature of your game / camera.

from smoothing-addon.

aladvs avatar aladvs commented on August 16, 2024

That is correct, but it does allow for some more freedom. With this approach, my "Player" node can stay as a CharacterBody3D, which allows positional
smoothing without smoothing its rotation, allowing for exact control over the camera.

from smoothing-addon.

lawnjelly avatar lawnjelly commented on August 16, 2024

Ah sorry, I get what you mean. This may well be an oversight on my part, will look into it when I get a moment. 👍 😃

from smoothing-addon.

bryanmylee avatar bryanmylee commented on August 16, 2024

I've managed to solve this problem by modifying the addon. Since my player is translated on the physics tick but rotated on the process tick, I needed a way to selectively apply interpolation on a per-property basis. To do so, I made this change:

func _process(_delta):

	var f = Engine.get_physics_interpolation_fraction()
	var tr: Transform3D = Transform3D()

	# translate
	if _TestFlags(SF_TRANSLATE):
		var ptDiff = _m_trCurr.origin - _m_trPrev.origin
		tr.origin = _m_trPrev.origin + (ptDiff * f)
+	else:
+		tr.origin = _m_Target.global_transform.origin

	# rotate
	if _TestFlags(SF_BASIS):
		if _TestFlags(SF_SLERP):
			tr.basis = _m_trPrev.basis.slerp(_m_trCurr.basis, f)
		else:
			tr.basis = _LerpBasis(_m_trPrev.basis, _m_trCurr.basis, f)
+	else:
+		tr.basis = _m_Target.global_transform.basis

	transform = tr

I'm not sure if this was the intention initially, but disabling the basis or translate flag OOTB causes the transform to never be applied at all. With the change, I can configure the smoothing node to only interpolate translate but leave basis as-is.

from smoothing-addon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.