This script in my opinion should’ve given some volocity to my gameobject onEnable, however he just appears befeore the camera and fall down.Can anyone help me with that problem?
using UnityEngine;
using System.Collections;
public class BulletProperties : MonoBehaviour
{
public float BulletSpeed = 10000;
void OnEnabled()
{
gameObject.rigidbody.velocity = new Vector3 (0, 0, BulletSpeed);
}
void OnCollisionEnter(Collision col)
{
this.gameObject.SetActive (false);
}
}
If the object is affected by gravity, it will fall. If the falling is fast enough, relative to the forward speed, you might not notice that it IS moving forward. You can turn off "use gravity" for the rigid body, to test.
@Paricus the thing is under void update so that is the issue. tried putting Application.LoadLevel(Application.loadedLevel); under case ShowResult.Failed: but it still shows 2 ads because it's not fast enough. there should be a thing that checks if the ad is already played so it won't show another but i don't know how.
try using the Start() function instead of OnEnabled. Start is always called when a new object is instantiated, but OnEnabled is not called, because the “enable” property wasn’t changed. It was always enabled.
Try this!
public float BulletSpeed = 10000;
void Start()
{
gameObject.rigidbody.velocity = new Vector3 (0, 0, BulletSpeed);
}
The problem is I am using (object pooling);Which is done in other script, Everything works fine except the movement of the object. As I understood OnEnabled() is similar to Start().The difference is that Start() is called once when the object is created and OnEnabled()is called everytime gameObject is SetActive(true).
@Paricus not replacing with SceneManagement. adds 4mt to the apk. and it didn't even fix the thing. need something to tell if the ad played to prevent more ads from playing
_ objectPoolingList*.transform.position = transform.position;_ _ objectPoolingList.transform.rotation = transform.rotation; objectPoolingList.SetActive(true); objectPoolingList.gameObject.rigidbody.velocity = new Vector3 (0, 0, 10); // pasted code* * break; } } }* And It worked. If someone knows the reason why it doesn’t work the way I’ve written first time will be happy to get the answer._
If the object is affected by gravity, it will fall. If the falling is fast enough, relative to the forward speed, you might not notice that it IS moving forward. You can turn off "use gravity" for the rigid body, to test.
– Glurth@Paricus the thing is under void update so that is the issue. tried putting Application.LoadLevel(Application.loadedLevel); under case ShowResult.Failed: but it still shows 2 ads because it's not fast enough. there should be a thing that checks if the ad is already played so it won't show another but i don't know how.
– Eemil_Ahonen