![]() Public CVector3 kinematicVelocity = null We therefore need to apply similar changes to the StudioListener.cs script.įirst, add the two members, and setKinematicVelocity() method, in the exact same manner as with StudioEventEmitter.cs: However, Doppler effect should be calculated from the point of the listener, who may also be moving. If it is null, this indicates that a rigidbody was found, and kinematicVelocity should be ignored. PositionLastFrame= Ĭall the above method it in Update(), but ONLY if kinematicVelocity is non-null. Next, add the following method to StudioEventEmitter.cs: void setKinematicVelocity()ĬurrentVel = Vector3.Lerp(currentVel, ( - positionLastFrame) / ltaTime, ltaTime * 15) //A very short lerp prevents jitter …StudioEventEmitter will now send kinematic data if a Rigidbody is not found. ![]() RuntimeManager.AttachInstanceToGameObject(instance, transform, kinematicVelocity) t3DAttributes(RuntimeUtils.To3DAttributes(ansform, kinematicVelocity)) RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody) t3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)) Next, we are going to expand the AttachedInstance class (found in RuntimeManager.cs) so that it can accommodate our CVector3 reference: Add the following to RuntimeUtils.cs: public static FMOD.ATTRIBUTES_3D To3DAttributes(Transform transform, CVector3 kinematicVelocity)įMOD.ATTRIBUTES_3D attributes = transform.To3DAttributes() I declared my class in RuntimeUtils.cs:įind RuntimeUtils.To3DAttributes, and overload it so it can take an instance of our class as a parameter. Using a class instead of a struct will simplify our method overloading, and slightly reduce the amount of code we need to re-write. ![]() In C#, classes are reference types by default. To achieve this, we can overload some functions in the FMOD C# scripts.įirst, create a class that has the same members as a Vector3. In order for your events’ doppler effects to work without rigidbodies, all that FMOD really needs is an FMOD.ATTRIBUTES_3D struct describing world-space velocity of the moving object, and the same for the listener. I know this is a very old post now, but I found myself asking the exact same question yesterday, so thought I’d leave my solution here for others to try.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |