- Home /
[Andorid; 2D; acceleration; Movment] Assets/Movments.js(7,38): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Vector3'.
Ok this is my second attemp in writting this :) .. First of I am completly new.. and I want to creat my first Andorid game.
I startet with a couple of tutorials and even managed to make some small tests run on my phone but now I am trying something I never did bevor, I tried to do it myself but I get one error after another.. I am really desperate for every little help I can get.
First of I want my Player (A Ball) to move right when you tilt the Phone to the right side. Left when you till it to the left side. And Jump when you shake it and or touch it (The screen)
Prohblem is I don't even get to the point where it starts moving at all.. This is my first try with sensors and just the simple movments are making me itchy. I would really love if somone could help me a bit or at least tell me if my thinking is totally wrong or not.
This here is my Code:
#pragma strict
var rotationSpeed = 100;
function Update ()
{
var rotation : float = Input.acceleration ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.zero * rotation);
}
well it works for keyinput controlls if I would change a segment but I have no Idea about acceleration..
Simply I want the ball to go faster the more I tild the Phone.. What is wrong with my Thinking?
Answer by Graham-Dunnett · Feb 13, 2014 at 09:30 PM
Input.acceleration
is a Vector3
. It's not a function, and doesn't take arguments.
Answer by redscaledone · Feb 14, 2014 at 04:23 PM
Thanks for the info I guess it is completlly wrong then.. Could somone give me a little help here? Only movment on the X Axis would be nice
so far I tried it with this here.
function Update () {
var dir : Vector3 = Vector3.zero;
dir.x = -Input.acceleration.y*.5;
transform.position.x += dir.x;
}