- Home /
How to edit one axis of the transform position
Hi, I'm trying to send information to FMOD from the Camera about where it is. My game is a 2.5d Platformer. Problem is, the camera is 300 away from the player-character (as it should be in a Platformer) so it's too far for FMOD to pick up. Could someone tell me how I can add 300 to the cameras transforms z position in this line so that FMOD thinks it's right on top of the player-character without actually changing the position of the camera. Here is the line in question.
pos = VectorConvert(this.transform.position);
The FMOD script in question is the player script which is basically the audio listener for 3D events. It tells FMODs sound system (another empty object) where the player is so that fmod can fade / filter / pan the sound appropriately. For it to pan appropriately it needs to be attached to the camera but it seems the camera is too far from the player-character to pick up the sound emitter it is approaching.
(Please don't tell me just to use the Unity audio as I am building a sound library in FMOD and this is literally the last thing I need to fix before it works! FMOD can do a lot more than Unity (2.61) can sound wise!)
Thanks!!
@Graeme, it's more clear, but still one question - you say "right on top of the player" - do you mean at the exact same location? Or do you need it several yards away for panning reasons (or something audio-related)?
If directly on top is easier that would probably work. It's easier to make something further away in F$$anonymous$$OD than it is to make it closer.
Answer by Cyclops · Jun 28, 2010 at 03:06 PM
I'm not entirely sure how you're representing FMOD in Unity, so this answer will be a bit vague, but it may give you some useful ideas.
First, when you say you want FMOD to be on/near the player - does FMOD have some kind of in-scene representation - say a GameObject?
Assuming it does have a GameObject, you have several options. First, you could make the FMOD GO a child object of the Player - just drag/drop it in the Hierarchy box. This will put it exactly where the Player object is. If you have already re-positioned the FMOD GO, you can either set its position to zero in the Editor, or use the Transform-Reset Component tab (also in the Editor).
If you wanted to change the FMOD GO's position at runtime, then you would just set its transform position to the Player's transform position - no conversion necessary. If you had this script on the FMOD GO:
function Start() {
this.gameObject.transform.position = somePlayer.transform.position;
}
Hope that helps - if not, you may need to clarify the Question. (And I'm curious what capabilities you need that Unity doesn't have - I thought that Unity 2.6 used FMOD?)
Update - if you just want the FMOD script/empty Object directly on top of the Player, that's simple - you just need a reference to the Player in the script (drag/drop), then set the Transform every frame:
var somePlayer : GameObject;
function Update() {
this.gameObject.transform.position = somePlayer.transform.position;
}
Yeah sorry, just realised that was very vague. It's actually quite hard to explain what I'm trying to do! :S I've edited it now so maybe that will be a bit more clear?!?!
Your answer
Follow this Question
Related Questions
transform position vectorially 2 Answers
Create a straight gradient equation with a grid of 3d objects 1 Answer
just update X and Z position of gameobject 1 Answer
Removing Vector3 Decimal for Position 2 Answers
How to communicate with matlab? 0 Answers