UE4で真下を向くとチカチカする!!

今回解決する問題

 

このように、「カメラが真下を向くと点滅してしまう!」という問題に遭遇した方へ向けた記事となります。

 

・Step1 PlayerCameraManager

  まず初めに、ContentBrowserで右クリックし、PlayerCameraManagerと入力します。ここで出てきたPlayerCameraManagerを作成してください。

 今回はBP_CameraManagerという名前を付けました。

 

 これをダブルクリックし、画面右のDetailsタブを見てください。

「ViewPitchMin」「ViewPitchMax」という項目を設定します。

ViewPitchMin”どれだけ下を向けるか”

ViewPitchMax”どれだけ上を向けるか” を設定できます。

設定し終わったらCompileしてください。

 

・Step2 PlayerController

 続いて、PlayerControllerを作成します。

これはBP_PlayerControllerと名付けました。

これもダブルクリックで開いてください。

 

・Step3 適用

 最後に、今まで作成してきたものを適用していきます。

 Step2で開いたBP_PlayerControllerPlayerCameraManagerClassに、Step1で作成したBP_CameraManagerを割り当て、Compileしてください。

 

 そして本当に最後の設定です。

ProjectSettingsPlayerControllerClassに、Step2のBP_PlayerControllerを割り当ててください。

 

・結果

これを実行すると……

 カメラの回転に制限がかかり、カメラの点滅がなくなりました!

 

 

 

 

Privacy Policy

Privacy Policy

[Developer/Company name] built the OFFTone app as [open source/free/freemium/ad-supported/commercial] app. This SERVICE is provided by [Developer/Company name] [at no cost] and is intended for use as is.

This page is used to inform visitors regarding [my/our] policies with the collection, use, and disclosure of Personal Information if anyone decided to use [my/our] Service.

If you choose to use [my/our] Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that [I/We] collect is used for providing and improving the Service. [I/We] will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at OFFTone unless otherwise defined in this Privacy Policy.

Information Collection and Use

For a better experience, while using our Service, [I/We] may require you to provide us with certain personally identifiable information[add whatever else you collect here, e.g. users name, address, location, pictures] The information that [I/We] request will be [retained on your device and is not collected by [me/us] in any way]/[retained by us and used as described in this privacy policy].

The app does use third-party services that may collect information used to identify you.

Link to the privacy policy of third-party service providers used by the app

Log Data

[I/We] want to inform you that whenever you use [my/our] Service, in a case of an error in the app [I/We] collect data and information (through third-party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing [my/our] Service, the time and date of your use of the Service, and other statistics.

Cookies

Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.

This Service does not use these “cookies” explicitly. However, the app may use third-party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.

Service Providers

[I/We] may employ third-party companies and individuals due to the following reasons:

  • To facilitate our Service;
  • To provide the Service on our behalf;
  • To perform Service-related services; or
  • To assist us in analyzing how our Service is used.

[I/We] want to inform users of this Service that these third parties have access to their Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.

Security

[I/We] value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and [I/We] cannot guarantee its absolute security.

Links to Other Sites

This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by [me/us]. Therefore, [I/We] strongly advise you to review the Privacy Policy of these websites. [I/We] have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.

Children’s Privacy

These Services do not address anyone under the age of 13. [I/We] do not knowingly collect personally identifiable information from children under 13 years of age. In the case [I/We] discover that a child under 13 has provided [me/us] with personal information, [I/We] immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact [me/us] so that [I/We] will be able to do the necessary actions.

Changes to This Privacy Policy

[I/We] may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. [I/We] will notify you of any changes by posting the new Privacy Policy on this page.

This policy is effective as of 2023-02-16

Contact Us

If you have any questions or suggestions about [my/our] Privacy Policy, do not hesitate to contact [me/us] at KusamaKyouhei@gmail.com.

This privacy policy page was created at privacypolicytemplate.net and modified/generated by App Privacy Policy Generator

Unityで角度に制限をかける方法

 今回は知らないと躓くかもしれない、Unityで回転を加える際に制限をかける方法を説明します。

 

原理

 早速ですがコードの紹介です。

 

見慣れない書き方だと思う人もいるかもしれませんので、19行目の説明をします。

 まず、

bool型 ? a : b ;

この形は、「もしbool型がTrueならばa(左)、Falseならばb(右)」という処理になります。if文で書くと、こうなります。

 

 目で見てわかるほどコードの量が減るため、if文を書くのが面倒くさいという場合にお勧めです。ただし、今回のように2重にする場合等はカッコで括るなどしないと分かりづらくなってしまいます。

 

 さて、続いては19行目の中身を解説していきます。と言っても、if分で書かれた内容から推察できてしまうかもしれません。そんな方は、この先の内容が自らの考えと一致しているか確認程度で見てください。

わざわざここまで面倒くさくしているのは、

回転する際の値が原因

です。これを見ている人は、制限をかけるとどうしても変な角度になってしまうと思います。それは、皆さんが考えている値実際に回転する際の値が異なっていることに起因します。

まずは次の画像を見てください。

 これがスクリプトで実際に計算しているときの回転の値となるわけですが、インスペクター上では0°から下げていくとマイナスになっていきます。このインスペクターの値を見て制限をかける際に 「-80 < x < 80」 のようにしてしまうと、予期しない挙動になってしまうわけです。そのため、このコードでは「280 < x < 360」と「0< x < 80」のように2段階に分けて処理を行っています。

 これさえ理解してしまえば、上記のコードと図を参考に、自由に回転に制限をかけることが出来ます。

 

[rakuten:book:20351971:detail]