I’m not a coder, I’m from the Art side, so please be patient.
I’m trying to use the accelerometer on IOS to steer a ship, this only works with the script I’m using if I have “is Kinematic” checked which I have verified from the documents.
The problem then becomes how to get it to crash when it hits things because OnCollisionEnter doesn’t work with “Is Kinematic”.
This is the C# script I have for the Accelerometer:
using UnityEngine;
using System.Collections;
public class AccelerometerInput : MonoBehaviour {
// Use this for initialization
void Update () {
transform.Translate(Vector3.forward * Time.deltaTime);
transform.Translate(Input.acceleration.x, 0, -Input.acceleration.z);
}
}
and this is the JS script for the collisions:
#pragma strict
function Start () {
// Plays the reload animation - stops all other animations
animation.Play("Fly fast", PlayMode.StopAll);
}
function OnCollisionEnter(col : Collision)
{
if(col.gameObject.name == "Bat_Death")
{
animation.wrapMode = WrapMode.Once;
animation.Play("Death", PlayMode.StopAll);
yield WaitForSeconds (.8);
Application.LoadLevel("StartWindow");
//audio.PlayOneShot(AudioClip);
}
}
Weirdly it seemed to work for a while, but I have no idea why and I do gather it isn’t supposed to.
It certainly isn’t now.
What is the simplest way to steer the ship with the accelerometer on an IOS device and still have the ship hit obstacles?
Doc says: Animation
For some situations, mainly creating ragdoll effects, it is neccessary to switch control of the object between animations and physics. For this purpose Rigidbodies can be marked isKinematic. While the Rigidbody is marked isKinematic, it will not be affected by collisions, forces, or any other part of the physics system. This means that you will have to control the object by manipulating the Transform component directly. Kinematic Rigidbodies will affect other objects, but they themselves will not be affected by physics. For example, Joints which are attached to Kinematic objects will constrain any other Rigidbodies attached to them and Kinematic Rigidbodies will affect other Rigidbodies through collisions.
So I have no idea why you’re using a kinematic Rigidbody
1: Did you miss the bit where I said I’m not a coder?
I’m using C# but the only script I’ve found that I could understand and adapt to do what I wanted in that case was in JS.
2: That’s what the Unity tutorial said to do.
I have read that doc and it just made me even more confused.
However, after reloading the whole project in a new version it is all working fine.
I don’t understand why or why it stopped working last time.
I’m just making a lot of backups before I change things.
I needed a rigidbody to collide with things.
My accelerometer script kept sending the player all over the place when isKinematic was not ticked.
Now in the new project it is working fine without is kinematic being ticked.
I have no idea what is different.
Well, if you can’t write C# scripts you’re going to have a very hard time making games in Unity3D… I recommend you invest the time to learn the basics of C#. I’m not a great coder myself, but once you understand the language you can just look in the docs and see what you need to do. There really is no point trying to make games in Unity3D if you don’t have a basic knowledge of C# (unless you work in a team with a programmer).
Thank you.
I have been doing nothing but tutorials from that link for the past two weeks.
Huge progress has actually been made.
I have got a very simple game framework going and it works.
I just have to get a scoring system that crosses levels sorted out and I’m sorted.
That was until I tried to build it to my iPhone.
208 Xcode errors for the Unity Editor.
None of which seem to relate to any of my scripts or Assets, they are things I’ve never seen before.
Not really included to throw good money after bad by upgrading to 5 after this never mind having to relearn for the third time the ever changing Unity interface at this point.
…and now, for absolutely no reason that I can find as I haven’t done anything differently, the Xcode build worked and the game is on my phone.
No idea what happened to the 208 errors.
Baffling.
Glad to see things worked out! Looks like Macs aren’t as error-free as Apple claims they are
Also I forgot that I do have a virtual machine running El Capitan (the latest OSX I think, before Sierra). Don’t even know why I have it since I never used it.
Once you get your app published I highly recommend upgrading to the latest version of Unity. You’re missing out on so much!