fehaar / FFWD

This is the FFWD framework for XNA, that allows you to port Unity3D games to XNA for use on WP7 or XBox360 (XBLIG)
Microsoft Public License
133 stars 36 forks source link

Transfrom == null on Renderer (MeshRenderer) object. #48

Open pmyn opened 12 years ago

pmyn commented 12 years ago

Hello, in Unity i create Game Object, add MeshRenderer with material texture and create Prefab with this GO. Export all to XNA, when i create GO on method UpdateCullingInfo(Camera cam) transform == null and throw Null Exception. Maybe i do somethink wrong, if you know this issue please some tips. Realy Thanks.

fehaar commented 12 years ago

It sounds odd that you would get a transform == null exception. Gameobjects should always have a transform in place. Can you post some code I can look at?

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

pmyn commented 12 years ago

On screen touch i create Bullet :
void HandleBullets() { tempVector = Quaternion.AngleAxis(8f, Vector3.up) * inputRotation; tempVector = (transform.position + (tempVector.normalized * 0.8f)); GameObject objCreatedBullet = (GameObject)Instantiate(ptrScriptVariable.objBullet, tempVector,Quaternion.LookRotation(inputRotation)); // create a bullet, androtate it based on the vector inputRotation Physics.IgnoreCollision(objCreatedBullet.collider, collider); }

and its bullet script : public class BulletScript : MonoBehaviour {

// Use this for initialization
private float moveSpeed = 30f; // how fast the bullet moves
private float timeSpentAlive; // how long the bullet has stayed alive for
private GameObject objPlayer;
public override void Start()
{
    objPlayer = (GameObject)GameObject.FindWithTag("Player");
}

// Update is called once per frame
public override void Update()
{
    timeSpentAlive += Time.deltaTime;
    if (timeSpentAlive > 1) // if we have been traveling for more than onesecond remove the bullet
    {
        removeMe();
    }
    // move the bullet
    transform.Translate(0, 0, moveSpeed * Time.deltaTime);
    transform.position = new Vector3(transform.position.x,
    0, transform.position.z); // because the bullet has a rigid body we don't want itmoving off it's Y axis
}
void removeMe()
{
    Destroy(gameObject);
}
public override void OnCollisionEnter(Collision Other)
{
    if (Other.gameObject.GetComponent(typeof(AIScript)) != null &&
    Other.gameObject != objPlayer) // if we have hit a character and it is not theplayer
    {
        removeMe();
    }
    removeMe(); // remove the bullet if it has hit something else apart froman enemy character
}

} Exception : System.NullReferenceException was unhandled Message=NullReferenceException StackTrace: at PressPlay.FFWD.Components.RenderItem.UpdateCullingInfo(Camera cam, Transform t) at PressPlay.FFWD.Components.Renderer.UpdateCullingInfo(Camera cam) at PressPlay.FFWD.Components.Camera.Culling() at PressPlay.FFWD.Application.Draw(GameTime gameTime) at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime) at FFWD.Unity.Tests.Game1.Draw(GameTime gameTime) at Microsoft.Xna.Framework.Game.DrawFrame() at Microsoft.Xna.Framework.Game.Tick() at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e) at Microsoft.Xna.Framework.GameHost.OnIdle() at Microsoft.Xna.Framework.MobileGameHost.RunOneFrame() at Microsoft.Xna.Framework.MobileGameHost.gameLoopTimer_Tick(Object sender, EventArgs e) at Microsoft.Xna.Framework.DispatcherTimerWin32.TimerElapsed(IntPtr hWnd, UInt32 uMsg, IntPtr nIDEvent, UInt32 uTime)

I Develop on Windows Phone. Edit : When i delete MeshRenderer from GO everythink is okey (off course not see objects on scene).