• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Aug 26, 2014 at 05:47 PM by fueldown for the following reason:

Problem is outdated

avatar image
0
Question by fueldown · Aug 21, 2012 at 07:50 PM · c#accelerometergyroscope

Using custom accelerometer, gyro & magnetometer to move objects

Hello, So, here's my problem: I am using 2 9 DoF (3X Accel, 3X Gyro, 3X Mag) modules to implement a motion capture billiards game. In order to control the cue, I need to assign the readings to transformation of my Cue GameObject. My sensors give me linear and angular accelerations in real values (m/sec^2 and rad/sec^2). I am really stuck as I have programmed the entire driver for the sensors and the game, but I couldn't integrate the two parts.

Does anyone have any idea as to how I can apply this data to control the cue? Any kind of help is appreciated.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dhmaxhd · Sep 03, 2020 at 11:59 AM 0
Share

How do I make a player shoot right and left 2D platformer firing left and right, help! using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.CrossPlatformInput;

public class movo : $$anonymous$$onoBehaviour { float bulletSpeed = 500f; public Animator anim; public Transform barrel; public Rigidbody2D bullet; private Rigidbody2D rb; private bool moveLeft; private bool moveRight; private float horizontal$$anonymous$$ove; public float speed = 5; public SpriteRenderer sp;

 private void Start()
 {
     anim = GetComponent<Animator>();
     rb = GetComponent<Rigidbody2D>();
     sp = GetComponent<SpriteRenderer>();
 
     moveLeft = false;
     moveRight = false;
 }
 
 public void PointerDownLeft()
 {
     anim.SetBool("run", true);
     moveLeft = true;
 }
 
 public void PointerUpLeft()
 {
     anim.SetBool("run", false);
     moveLeft = false;
 }
 
 public void PointerDownRight()
 {
     anim.SetBool("run", true);
     moveRight = true;
 }
 
 public void PointerUpRight()
 {
     anim.SetBool("run", false);
     moveRight = false;
 }
 
 void Update()
 {
     $$anonymous$$ovementPlayer();
     if (CrossPlatformInput$$anonymous$$anager.GetButtonDown ("Fire1"))
         Fire ();
 }
 
 void $$anonymous$$ovementPlayer()
 {
     if (moveLeft)
     {
         sp.flipX = true;
         horizontal$$anonymous$$ove = -speed;
     }
 
     else if (moveRight)
     {
         sp. flipX = false;
         horizontal$$anonymous$$ove = speed;
     }
 
     else
     {
         horizontal$$anonymous$$ove = 0;
     }
 }
 
 private void FixedUpdate()
 {
     rb.velocity = new Vector2(horizontal$$anonymous$$ove, rb.velocity.y);
 }

 void Fire()
 {
     var firedBullet = Instantiate (bullet, barrel.position, barrel.rotation);
     firedBullet.AddForce (barrel.up * bulletSpeed);
 }

}

1 Reply

  • Sort: 
avatar image
0

Answer by avr · Jul 12, 2014 at 03:08 AM

The best way to do it is using sensor fusion methods based on unscented Kalman filters/ sigma point filters

Note: you need accurate time stamps of all measurements.

this may be helpful for a start, though based on extended Kalman filter instead of unscented https://github.com/ethz-asl/ethzasl_sensor_fusion

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to judge intensity of shaking in android phones 1 Answer

Distribute terrain in zones 3 Answers

A node in a childnode? 1 Answer

Match Object (Main Camera) To Gyroscope Rotation Rate 1 Answer

Multiple Cars not working 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges