Unity Simple Car

1、需要在Rigid Body下构造轮子,否则在Editor窗口看不到wheel Collider的轮廓
2、需要把车的mess设置大一点1000,否则很容易被轮子给弹出地面
3、轮子的模型和Wheel Collider在Rotation都为0时坐标轴方向一致,否则之后旋转不对
4、轮胎的高度位置需要一致,防止离地或其他原因导致车无法走动
5、只需要给两个轮子添加动力,其他的轮子会跟着旋转
6、轮胎真实的模型旋转和位置需要从whell collider中获取
7、没有设置动力的轮胎只需要设置旋转即可

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Car : MonoBehaviour {
	private WheelCollider Wheel;
	public Transform realWheal;
	public float angle = 10;
	public float motor = 10;
	// Use this for initialization
	void Awake () {
		Wheel = gameObject.GetComponent<WheelCollider>();
	}
	
	// Update is called once per frame
	void FixedUpdate() {
		//方向盘旋转的轮胎角度
		Wheel.steerAngle = angle;
		//正为向前动力,负为向后动力,0为空挡滑行
		Wheel.motorTorque = motor;

		Vector3 pos;
		Quaternion rot;
		Wheel.GetWorldPose(out pos,out rot);
		realWheal.position = pos;
		realWheal.rotation = rot;
	}
}

下载地址:Unity工程

参考:
https://docs.unity3d.com/ScriptReference/WheelCollider.html

首先需要了解得物网站的数据结构和爬取方式,得物网站比较复杂,需要使用Selenium+BeautifulSoup进行爬取。 以下是一个简单的得物爬虫Python代码实现(注:仅供学习参考,请勿用于商业用途): ```python import time from selenium import webdriver from selenium.webdriver.chrome.options import Options from bs4 import BeautifulSoup options = Options() options.add_argument('--no-sandbox') # 解决DevToolsActivePort文件不存在报错的问题 options.add_argument('window-size=1920x3000') # 指定浏览器分辨率 options.add_argument('--disable-gpu') # 谷歌文档提到需要加上这个属性来规避bug options.add_argument('--hide-scrollbars') # 隐藏滚动条, 应对一些特殊页面 options.add_argument('blink-settings=imagesEnabled=false') # 不加载图片, 提升速度 options.add_argument('--headless') # 无界面 driver = webdriver.Chrome(options=options) url = 'https://www.dewu.com/' driver.get(url) # 等待页面加载完成 time.sleep(3) # 模拟鼠标点击,展开商品列表 driver.find_element_by_xpath('//div[text()="全部商品"]').click() # 等待页面加载完成 time.sleep(3) # 获取页面源代码 html = driver.page_source # 解析页面 soup = BeautifulSoup(html, 'html.parser') # 获取商品列表 items = soup.find_all('div', {'class': 'item-card'}) for item in items: # 获取商品标题 title = item.find('div', {'class': 'title'}).text.strip() # 获取商品价格 price = item.find('div', {'class': 'price'}).text.strip() # 获取商品链接 link = item.find('a', {'class': 'item-link'})['href'] print(title, price, link) # 关闭浏览器 driver.quit() ``` 这里的代码仅仅是一个简单的爬虫示例,如果想要更加深入地了解得物网站的数据结构和爬取方式,需要结合具体的需求进行更加详细的分析和实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值