[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/agdg/ - Amateur Game Development General

AGDG - The Board

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)

You may buy ads now for any board, betakey is removed. Please contact ads@8ch.net for information or help with this service.
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
dicesidesmodifier
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 5 per post.


Welcome to AGDG, have you ever made a game?
See also: /ideaguy/ | /vm/

File: 1439935253189.jpg (215.72 KB, 1920x1200, 8:5, 8t5OoYW.jpg)

a3b141 No.21030

I've been away from /agdg/ for some time and I figured this would probably be the right place to ask for help of this sort of magnitude. I can not for the life of me understand scripting for cellphone controls. I was wondering if someone could change my script to work with the accelerometer to take over what would be WASD and tapping the screen for what would be the SPACEBAR. Thank you for those of you who lend a hand to my conundrum.

(picture obviously and entirely unrelated unless you count the tiger as my brain awash in a sea of algae script)

#pragma strict

var rotationSpeed = 100;

var jumpHeight = 8;

private var isFalling = false;

function Update ()

{

//Handle ball rotation.

var moveHorizontal : float = Input.GetAxis("Horizontal");

var moveVertical : float = Input.GetAxis("Vertical");

var movement : Vector3 = new Vector3(moveHorizontal, 0.0, moveVertical);

GetComponent.<Rigidbody>().AddForce(movement * rotationSpeed * Time.deltaTime);

if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)

{

GetComponent.<Rigidbody>().velocity.y = jumpHeight;

isFalling = true;

}

}

function OnCollisionStay ()

{

isFalling = false;

}

290420 No.21032

https://unity3d.com/learn/tutorials/modules/beginner/platform-specific/accelerometer-input

I don't believe i have the required software to export to Android so that's the best you'll get from me. Besides, you're using JS.


f07bdd No.21035

I don't know shit about Unity or cellphones, but a lot of analog inputs are normalized to fall within the range of 0..1 (shoulder trigger) or -1..+1 (axis)

Is this C#? I've literally never seen this syntax

>var moveHorizontal : float = Input.GetAxis("Horizontal");

Also, GetComponent<Rigidbody>() is a function call which returns a component. You should create a variable to hold this reference, rather than invoking the GetComponent method each time, as it might become slow or costly in large or complex blocks of code


var c = GetComponent<Rigidbody>();
c.AddForce(...);
c.velocity.y = jumpHeight;

etc

Sorry I didn't answer your question


a3b141 No.21037

>>21032

Yes I am using JS. What's your point.

>>21035

JavaScript, dear friend. JavaScript.


65f8d6 No.21173

>>21166

technically it does make the force smaller, but it also makes it consistent no matter what clock speed the cpu is running at, so more powerful pones don't play the game faster than it should be.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]